Package VC Controls in BCB Codesense

zhaozj2021-02-16  148

Q: http://community.9cbs.net/expert/topic/3179/3179109.xml?temp=.7848627

The author wants an OCX solution, I have not given it. BCB has always been a lot of disease in this area, huh, huh. However, his control is Open Source. The original authors developed by VC MFC, but the interface is API message. This kind of VCL to encapsulate this control is not very difficult.

CodeSense is an editing control of a source color.

This is the download address of the original file.

Http://www.ticz.com/homes/USERS/nlewis/html/software_development/codesense/download/codesense/cmcs222.zip

You need to export import library with Implib -a cmcs21.lib cmcs21.dll before use.

The following packages I made:

#include

#define _t // address by cker. a dirty hack.

#include "codesense.h"

#include

#define assert assert

Class TcodesenseCtrl: Public TwinControl

{

protected:

Virtual void __fastcall createparams (Controls :: TcreateParams & params)

{

CmregisterControl ();

TwinControl :: CreateParams (Params);

CreateSubclass (params, codesensewndclass);

}

PUBLIC:

__fastcall Virtual TcodesenseCtrl (Tcomponent * aowner): TwinControl (Aowner)

{

}

__fastcall virtual ~ tcodensensECtrl ()

{

CmunregisterControl ();

}

PUBLIC:

CME_code setLanguage (LPCTSTR PSZNAME)

{

Return cm_setlanguage (handle, pszname);

}

CME_code getLanguage (LPTSTR PSZNAME)

{

Return Cm_GetLanguage (Handle, Pszname);

}

CME_code enablecolorsyntax (Bool Benable = true)

{

Return cm_enablecolorsyntax (Handle, Benable);

}

Bool iscolorsyntaxenabled ()

{

Return cm_iscolorsyntaxenabled (Handle);

}

CME_code openfile (LPCTSTR PSZFileName)

{

Return cm_openfile (Handle, PSZFileName);

}

CME_CODE INSERTFILE (LPCTSTSTST PSZFILENAME, ConST cm_position * ppos = null)

{

Return CM_INSERTFILE (HANDLE, PSZFILENAME, PPOS);

}

CME_code inserttext (lpctstr psztext, const cm_position * ppos = NULL)

{

Return CM_INSERTTEXT (HANDLE, PSZTEXT, PPOS);

}

CME_code setText (lpctstr psztext) {

Return Cm_Settext (Handle, PSzText);

}

CME_code setColors (const cm_colors * pcolors)

{

Return CM_SETCOLORS (HANDLE, PCOLORS);

}

CME_code getcolors (cm_colors * pcolors)

{

Return CM_Getcolors (Handle, Pcolors);

}

CME_code enableWhitespaceDisplay (Bool Benable = True)

{

Return Cm_enablewhitespaceDisplay (Handle, Benable);

}

Bool iswhitespacedisplayenabled ()

{

Return cm_iswhitespacedisplayenabled (handle);

}

CME_code enabletabexpand (Bool Benable = true)

{

Return CM_ENABETABEXPAND (HANDE, BENABLE);

}

Bool iStabexpandenabled ()

{

Return cm_istabexpandenabled (handle);

}

CME_code enablesplesmoothscrolling (Bool Benable = true)

{

Return cm_enablesmoothscrolling (handle, benable);

}

Bool issmoothscrollingenablend ()

{

Return cm_issmoothscrollingenabled (handle);

}

CME_code settabsize (int NTABSIZE)

{

Return Cm_SetTabsize (Handle, NTABSIZE);

}

INT getTabsize ()

{

Return cm_gettabsize (handle);

}

CME_code setReadonly (Bool Breadonly = True)

{

Return cm_setreadonly (Handle, BreadOnly);

}

Bool isreadOnly ()

{

Return cm_isreadonly (Handle);

}

CME_code enablelinetooltips (Bool Benable = True)

{

Return cm_enablelinetooltips (Handle, Benable);

}

Bool islinetooltipsenabled ()

{

Return cm_islinetooltipsenabled (handle);

}

CME_code enableleftmargin (Bool Benable = True)

{

Return cm_enableeleftmargin (Handle, Benable);

}

Bool isleftmarginenabled ()

{

Return Cm_ILFTMARGINENABED (HANDLE);

}

CME_Code Savefile (LPCTSTSTST PSZFILENAME, BOOL BCLARUNDO = TRUE)

{

Return cm_savefile (Handle, PszFileName, BClearundo);

}

CME_CODE ReplaceText (LPCTSTSTST PSZTEXT, Const CM_RANGE * PRANGE = NULL)

{

Return CM_ReplaceText (Handle, Psztext, PRANGE);

}

INT getTextLength (const cm_range * prange = null, bool blogical = false)

{

Return Cm_GettextLength (Handle, PRANGE, BLOGICAL);

}

CME_CODE GETTEXT (LPTSTSTSTSTSTSTSZBUFF, CONST CM_RANGE * PRANGE = NULL)

{

Return Cm_Gettext (Handle, PszBuff, PRANGE);

}

// cme_code gettext (CSTRING & STRTEXT, Const CM_RANGE * PRANGE = NULL)

// {ask (:: iswindow (handle));

// cme_code ncode = cm_gettext (Handle, Strtext.getBuffersetLength 1), PRANGE

// strText.releaseBuffer ();

// return ncode;}

CME_CODE GETLINE (int NLINE, LPTSTSTSTSTSZBUF)

{

Return CM_GETLINE (Handle, NLINE, PSZBUF);

}

// cme_code getLine (int nline, cstring & strline)

// {ask (:: iswindow (handle));

// cme_code ncode = cm_getline (handle, nline, strline.getBuffersetLength);

// strline.releasebuffer ();

// return ncode;}

INT getLineCount ()

{

Return cm_getlinecount (handle);

}

INT getLineLength (int nline, bool blogical = false)

{

Return cm_getlinelarth (handle, nline, blogical);

}

CME_CODE GETWORD (LPTSTSTSTSTSZBUF, CM_PSITION * PPOS)

{

Return CM_GetWord (Handle, PSZBuff, PPOS);

}

// cme_code getWord (CSTRING & STRWORD, CM_PSITION * PPOS)

// {ask (:: iswindow (handle));

// cme_code ncode = cm_getword (handle, strWord.getBuffersetlength); PPOS);

// strWord.releaseBuffer ();

// return ncode;}

INT getWordLength (cm_position * ppos, bool blogical = false)

{

Return CM_GetWordLength; Handle, PPOS, Blogical;

}

CME_CODE AddText (LPCTSTR PSZText) {

Return CM_AddText (Handle, PSzText);

}

CME_code deleteLine (int nline)

{

Return cm_deleteline (Handle, NLINE);

}

CME_code insertline (int Nline, LPCTSTR PSZTEXT)

{

Return CM_INSERTLINE (Handle, NLINE, PSZTEXT);

}

CME_CODE GETSEL (CM_RANGE * PRANGE, BOOL BNORMALIZED = TRUE)

{

Return Cm_getsel (Handle, PRANGE, BNORMALIZED);

}

CME_CODE SETSEL (Const CM_RANGE * PRANGE, BOOL BMAKEVISIBLE = TRUE)

{

Return CM_Setsel (Handle, PRANGE, BMAKEVISIBLE);

}

CME_CODE DELETESEL ()

{

Return cm_deletesel (handle);

}

CME_code replasel (LPCTSTSTSTSZTEXT)

{

Return CM_ReplaceEl (Handle, PSzText);

}

CME_CODE EXECUTECMD (Word WCMD, DWORD DWCMDDATA = 0)

{

Return CM_EXECUTECMD (Handle, WCMD, DWCMDDATA);

}

CME_code setsplitterpos (Bool Bhorz, int NPOS)

{

Return CM_SETSPLITTERPOS (Handle, Bhorz, NPOS);

}

INT GetSplitterpos (Bool Bhorz)

{

Return Cm_getsplitterpos (Handle, Bhorz);

}

CME_code setAutoindentMode (int nmode)

{

Return cm_setautoindentMode (Handle, NMODE);

}

Int getautoindentmode ()

{

Return cm_getautoindentmode (handle);

}

Bool cancopy ()

{

Return cm_cancopy (handle);

}

Bool cancut ()

{

Return CM_CANCUT (HANDLE);

}

Bool canpaste ()

{

Return cm_canpaste (handle);

}

CME_code copy ()

{

Return cm_copy (handle);

}

CME_CODE CUT ()

{

Return CM_CUT (HANDLE);

}

CME_Code Paste ()

{

Return CM_Paste (Handle);

}

Bool canundo ()

{

Return CM_CANUNDO (HANDLE);

}

Bool canredo ()

{

Return CM_CANREDO (Handle);

}

CME_CODE REDO ()

{

Return cm_redo (handle);

}

CME_CODE undo ()

{

Return CM_UNDO (HANDLE);

}

CME_code clearundobuffer ()

{

Return cm_clearundobuffer (Handle);

}

CME_CODE SETUNDOLIMIT (INT NLIMIT) {

Return Cm_setundolimit (Handle, NLimit);

}

INT getundolimit ()

{

Return Cm_Getundolimit (Handle);

}

Bool ismodified ()

{

Return Cm_ismodified (Handle);

}

CME_code setmodified (bool bmodified = true)

{

Return Cm_SetModified (Handle, BModified);

}

CME_code enableoVertype (Bool Benable = true)

{

Return Cm_enableOvertype (Handle, Benable);

}

Bool isovertypeenabled ()

{

Return CM_ISOVERTYPEENABLED (HANDLE);

}

CME_code enablecasensensitive (Bool Benable = True)

{

Return cm_enablecasensensitive (handle, benable);

}

Bool iscasesensitiveEnabled ()

{

Return CM_IScaseSensitiveEnabled (Handle);

}

CME_code enablepreservecase (Bool Benable = True)

{

Return cm_enablepreservecase (Handle, Benable);

}

Bool isprservecasenabled ()

{

Return cm_ispreservecaseenabled (handle);

}

CME_code enableWholeWord (Bool Benable = True)

{

Return Cm_enableWholeWord (Handle, Benable);

}

Bool iswholeWordenabled ()

{

Return cm_iswholeWordenabled (Handle);

}

CME_code enableregexp (Bool Benable = true)

{

Return CM_ENABLEREGEXP (HANDE, BENABLE);

}

Bool isRegexpenabled ()

{

Return cm_isregExpenabled (Handle);

}

CME_code settopindex (int nview, int nline)

{

Return CM_SettopIndex (Handle, NView, NLIN);

}

INT gettopindex (int NView)

{

Return CM_GettopIndex (Handle, NView);

}

Int getVisibleLineCount (int nview, bool bfullyvisible = true)

{

Return Cm_GetvisibleLineCount (Handle, NView, Bfullyvisible);

}

CME_code enablecrlf (Bool Benable = True)

{

Return cm_enablecrlf (Handle, Benable);

}

Bool iscrlfenabled ()

{

Return cm_iscrlfenabled (handle);

}

CME_code setFontownership (Bool Benable)

{

Return Cm_setFontownership (Handle, Benable);

Bool getFontownership ()

{

Return Cm_GetFontownership (Handle);

}

Int getCurrentView ()

{

Return Cm_GetcurrentView (Handle);

}

CME_code setCurrentView (int NView)

{

Return Cm_SetCurrentView (Handle, NView);

}

INT getViewcount ()

{

Return Cm_GetViewCount (Handle);

}

CME_Code Showscrollbar (Bool Bhorz, Bool Bshow = true)

{

Return Cm_Showscrollbar (Handle, Bhorz, Bshow);

}

Bool Hasscrollbar (Bool Bhorz)

{

Return CM_HASSCROLLBAR (HANDLE, BHORZ);

}

CME_CODE GETSELFROMPOINT (int xclient, int yclient, cm_position * ppos)

{

Return Cm_getselFromPoint (Handle, XClient, YClient, PPOS)

}

CME_Code Selectline (int nline, bool bmakevisible = true)

{

Return Cm_SelectLine (Handle, NLINE, BMAKEVISIBLE);

}

int hittest (int Xclient, int yclient)

{

Return CM_Hittest (Handle, XClient, YClient);

}

CME_code enabledragdrop (Bool Benable = True)

{

Return cm_enabledragdrop (Handle, Benable);

}

Bool isdragdropenabled ()

{

Return cm_isdragdropenabled (handle);

}

CME_CODE EnableSplitter (Bool Bhorz, Bool Benable = True)

{

Return cm_enablesplitter (Handle, Bhorz, Benable);

}

Bool Issplitterenabled (Bool Bhorz)

{

Return CM_ISSPLitterenabled (Handle, Bhorz);

}

CME_code enablecolumnel (Bool Benable = true)

{

Return cm_enablecolumnel (handle, benable);

}

Bool iscolumnlenabled ()

{

Return cm_iscolumnlenabled (handle);

}

CME_code enableglobalprops (Bool Benable = true)

{

Return cm_enableglobalprops (handle, benable);

}

Bool isglobalpropsenabled ()

{

Return cm_isglobalpropsenabled (Handle);

}

Bool isrecordingmacro ()

{

Return cm_isrecordingmacro (Handle);

}

Bool isplayingmacro ()

{

Return cm_isplayingmacro (Handle);

CME_CODE SETDLGPARENT (HWND * HWND)

{

Return cm_setdlgparent (Handle, Hwnd);

}

CME_CODE EnableSelbounds (Bool Benable = True)

{

Return cm_enableselbounds (handle, benable);

}

Bool isselboundsenabled ()

{

Return cm_isselboundsenabled (handle);

}

CME_CODE SETFONTSTYLES (cm_fontstyles * pfontstyles)

{

Return Cm_setFontStyles (Handle, PFontStyles);

}

CME_code getFontStyles (cm_fontstyles * pfontstyles)

{

Return CM_GETFONTSTYLES (HANDE, PFONTSTYLES);

}

CME_code setItemData (int nline, lparam lparam)

{

Return CM_SETITEMDATA (HANDLE, NLINE, LPARAM);

}

LParam GetItemData (int nline)

{

Return cm_getitemdata (Handle, NLINE);

}

CME_code setLinesTyle (int Nline, DWORD DWSTYLE)

{

Return CM_SETLINESTYLE (HANDLE, NLINE, DWSTYLE);

}

DWORD GETLINESTYLE (INT NLINE)

{

Return cm_getlinesTyle (Handle, NLINE);

}

CME_code setBookmark (int nline, bool Benable = true)

{

Return CM_SetBookmark (Handle, NLINE, BENABLE);

}

Bool getBookmark (int NLINE)

{

Return Cm_GetBookmark (Handle, NLINE);

}

CME_code setAllBookmarks (int Ncount, LPDWORD PDWLINES)

{

Return Cm_setallBookmarks (Handle, Ncount, Pdwlines);

}

Int getBookMarks (LPDWORD PDWLINES)

{

Return Cm_GetAllBookmarks (Handle, PDWLines);

}

CME_CODE SETLINENUMBERING (CM_LINENUMBERING * PNUMBERING)

{

Return cm_setLinenumbering (Handle, PNumbering);

}

CME_CODE GETLINENUMBERING (CM_LINENUMBERING * PNUMBERING)

{

Return cm_getlinenumbering (handle, pnumbering);

}

CME_CODE POSFROMCHAR (CM_Position * PPOS, LPRECT PreC)

{

Return CM_POSFromchar (Handle, PPOS, prect);

}

CME_code enablehidesel (Bool Benable = true)

{

Return CM_ENABLEHIDESEL (HANDE, BENABLE);

}

Bool ishideselenabled () {

Return cm_ishideselenabled (handle);

}

CME_Code STHighlightedLine (int NLINE)

{

Return cm_sethighlightedLine (Handle, NLINE);

}

Int gethighlightedLine ()

{

Return cm_gethighlightedline (Handle);

}

CME_CODE EnablenorMalizecase (Bool Benable = True)

{

Return cm_enablenorMalizecase (Handle, Benable);

}

Bool isnormalizecaseEnabled ()

{

Return cm_isnormalization (handle);

}

CME_code setdivider (int nline, bool benable = true)

{

Return CM_SETDIVIDER (Handle, NLINE, BENABLE);

}

Bool getDivider (int nline)

{

Return Cm_Getdivider (Handle, NLINE);

}

CME_code enableoverTypecaret (Bool Benable = true)

{

Return cm_enableoverTypecaret (Handle, Benable);

}

Bool isovertypecareTenabled ()

{

Return cm_isovertypecareTenabled (Handle);

}

CME_code setFindText (LPCTSTR PSZTEXT)

{

Return CM_SetFindText (Handle, PSzText);

}

CME_code getFindText (LPTSTR PSZTEXT)

{

Return Cm_GetFindText (Handle, PSzText);

}

// cme_code getFindText (CSTRING & STRTEXT)

// {

// cme_code ncode = cm_getfindtext (handle, strText.getBuffersetLength);

// strText.releaseBuffer ();

// Return ncode;

//}

CME_code setReplaceXT (LPCTSTR PSZTEXT)

{

Return Cm_SetReplaceText (Handle, PSzText);

}

CME_code getReplaceXT (LPTSTSTSTSTSTSTSTEXT)

{

Return cm_getreplacetext (handle, psztext);

}

// cme_code getReplaceText (CSTRING & STRTEXT)

// {

// cme_code ncode = cm_getreplacetext (handle, strText.getBuffersetlength);

// strText.releaseBuffer ();

// Return ncode;

//}

CME_code setimagelist (himagelist himagelist)

{

Return cm_setimagelist (HIMAGELIST);

Himagelist getimagelist ()

{

Return cm_getimagelist (handle);

}

CME_code setmarginimages (int nline, byte byimages)

{

Return CM_SETMARGINIMAGES (Handle, NLINE, BYIMAGES);

}

Byte get MarginImages (int nline)

{

Return cm_getmarginimages (Handle, NLINE);

}

CME_code Aboutbox ()

{

Return CM_AboutBox (Handle);

}

CME_CODE Print (HDC HDC, DWORD DWFLAGS)

{

Return CM_Print (Handle, HDC, DWFLAGS);

}

CME_CODE SETCARETPOS (int nline, int ncol)

{

Return CM_SETCARETPOS (Handle, NLINE, NCOL);

}

INT ViewColTobuffercol (int nline, int nviewcol)

{

Return CM_ViewColTobuffercol (Handle, NLINE, NVIEWCOL);

}

Int buffercoltoviewcol (int nline, int nbuffercol)

{

Return CM_BufferColToviewCol (Handle, NLINE, NBUFFERCOL);

}

CME_code setBorderstyle (DWORD DWSTYLE)

{

Return Cm_setBordersTyle (Handle, DWStyle);

}

DWORD getBorderstyle ()

{

Return cm_getborderstyle (handle);

}

DWORD getCurrentToken ()

{

Return cm_getcurrentToken (Handle);

}

Void updateControlPositions ()

{

CM_UPDATECONTROLPSITIONS (HANDLE);

}

}

Comment is about the part of the cstring, there is no great meaning. Surrounding the encapsulation of Ansistring.

Below is a call example:

/ / -------------------------------------------------------------------------------------------- ----------------------

#include

#pragma HDRSTOP

#include "unit1.h"

#include "codesense.h"

#include "tcodesensectrl.h"

/ / -------------------------------------------------------------------------------------------- ----------------------

#pragma package (smart_init)

#pragma resource "* .dfm"

TFORM1 * FORM1;

/ / -------------------------------------------------------------------------------------------- ----------------------

TCODESENSECTRL * S;

__fastcall tform1 :: tform1 (tComponent * Owner)

: TFORM (OWNER)

{

}

/ / -------------------------------------------------------------------------------------------- ---------------------- Void __fastcall tform1 :: formdestroy (TOBJECT * SENDER)

{

Delete S;

}

/ / -------------------------------------------------------------------------------------------- ----------------------

Void __fastcall tform1 :: formcreate (TOBJECT * SENDER)

{

S = New TcodeSenseCtrl (this);

Panel1-> Doublebuffered = true;

S-> Parent = panel1;

S-> align = alclient;

S-> Visible = true;

S-> setLanguage (cmlang_cpp);

S-> enablecolorsyntax ();

S-> Showscrollbar (FALSE);

S-> Showscrollbar (TRUE);

S-> Enablesplitter (false, true);

S-> Enablesplitter (True, true);

:: SendMessage (Handle, WM_SETFONT, (INT) Panel1-> font-> handle, 0);

}

/ / -------------------------------------------------------------------------------------------- ----------------------

Void __fastcall tform1 :: button1click (Tobject * Sender)

{

IF (OpenDialog-> Execute ())

{

S-> OpenFile (OpenDialog-> filename.c_str ());

}

}

/ / -------------------------------------------------------------------------------------------- ----------------------

转载请注明原文地址:https://www.9cbs.com/read-7861.html

New Post(0)