March 28, 2024, 06:02:16 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Colorize text in real-time

Started by aurelCB, August 19, 2008, 02:16:51 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

aurelCB

Hi all...
I find this code made by Jos de Jong (Joske) and work ok on EBasic.
My question is :Is this posible convert this code to Creative.
Or maby do something similiar directly in Creative Basic.
Any idea ...?
Joske code:
/*
color code in rich edit control
ibasic pro code
jos de jong, 2007
*/

'Declarations
$INCLUDE "windows.inc"
CONST EM_FINDTEXT = (WM_USER + 56)
TYPE CHARRANGE
INT cpMin
INT cpMax
ENDTYPE
TYPE FINDTEXT
    CHARRANGE chrg
    POINTER lpstrText
ENDTYPE

'create a list with keywords
CONST kewordCount = 9
DEF keyword[kewordCount]:STRING
keyword[0] = "IF"
keyword[1] = "THEN"
keyword[2] = "ELSE"
keyword[3] = "ENDIF"
keyword[4] = "WHILE"
keyword[5] = "ENDWHILE"
keyword[6] = "DO"
keyword[7] = "FOR"
keyword[8] = "NEXT"


DEF d1:Dialog
CREATEDIALOG d1,0,0,587,360,0x80C80080,0,"Color code demo",&Handler
CONTROL d1,@RICHEDIT,"",7,35,570,294,0x50B010C4,1
DOMODAL d1
END


'______________________________________________________________________________
SUB Handler
SELECT @MESSAGE
CASE @IDINITDIALOG
CENTERWINDOW d1

'let the rich edit control send a message when the contents have changed
mask = CONTROLCMD(d1,1,@RTGETEVENTMASK)
CONTROLCMD d1, 1, @RTSETEVENTMASK, mask | @ENMKEYEVENTS |@ENMCHANGE

SETCONTROLTEXT d1, 1, "This program can highlight keywords\nlike then and if and while...\n\nAlso the words For, next, etc."

applyColorSheet(d1, 1)

CASE @IDCONTROL
SELECT @CONTROLID
CASE 1:'richedit
SELECT @NOTIFYCODE
CASE @ENCHANGE
'the contents of the richedit are changed
applyColorLine(d1, 1)
ENDSELECT
ENDSELECT

ENDSELECT
RETURN
ENDSUB



'______________________________________________________________________________
/*
This function adjusts the colors of all lines in the sheet
*/
SUB applyColorSheet(dlg:DIALOG, ctl:INT)
INT char_start, char_end
INT linenum, linecount

'hide the selection and get the current caret position
CONTROLCMD dlg, ctl, @RTHIDESEL, 1
CONTROLCMD dlg, ctl, @RTGETSELECTION, char_start, char_end

linecount = CONTROLCMD(dlg, ctl, @RTGETLINECOUNT)
FOR linenum = 0 TO linecount-1
colorize(dlg, ctl, linenum)
NEXT linenum

'restore the original caret position and show the selection again
CONTROLCMD dlg, ctl, @RTSETSELECTION, char_start, char_end
CONTROLCMD dlg, ctl, @RTHIDESEL, 0

RETURN
ENDSUB


'______________________________________________________________________________
/*
This function adjusts the colors of the current line
*/
SUB applyColorLine(dlg:DIALOG, ctl:INT)
INT char_start, char_end
INT linenum

'hide the selection and get the current caret position
CONTROLCMD dlg, ctl, @RTHIDESEL, 1
CONTROLCMD dlg, ctl, @RTGETSELECTION, char_start, char_end

linenum = CONTROLCMD (dlg, ctl, @RTLINEFROMCHAR, char_start)
colorize(dlg, ctl, linenum)

'restore the original caret position and show the selection again
CONTROLCMD dlg, ctl, @RTSETSELECTION, char_start, char_end
CONTROLCMD dlg, ctl, @RTHIDESEL, 0

RETURN
ENDSUB

'______________________________________________________________________________
/*
This function adjusts the colors of the keywords on the given linenum
*/
SUB colorize(dlg:DIALOG, ctl:INT, linenum:INT)
INT lineStart, lineLength
INT i
INT p, pLine

lineStart = CONTROLCMD (dlg, ctl, @RTCHARFROMLINE, linenum)
lineLength = CONTROLCMD (dlg, ctl, @RTGETLINELENGTH, linenum)

'uncolor the whole line, set black color
CONTROLCMD dlg, ctl, @RTSETSELECTION, lineStart, lineStart + lineLength
CONTROLCMD dlg, ctl, @RTSETSELCOLOR, RGB(0, 0, 0)

'check the keywords one by one, if they occur on this line
FOR i=0 TO kewordCount-1
p = lineStart-1
DO
p = RTFINDTEXT(dlg, ctl, keyword[i], p+1, lineStart + lineLength, True, True)
IF p >= 0
'the keyword is found at the current line. color it
CONTROLCMD dlg, ctl, @RTSETSELECTION, p, p+LEN(keyword[i])
CONTROLCMD dlg, ctl, @RTSETSELCOLOR, RGB(255, 0, 0)

''you can also add making the text uppercase and things like that...
'CONTROLCMD dlg, ctl, @RTREPLACESEL, UCASE$(keyword[i])
ENDIF
UNTIL p < 0
NEXT i

RETURN
ENDSUB


'________________________________________________________________________
SUB RTFINDTEXT(w:DIALOG, ctl:INT, Searchtext:STRING, start_pos:INT, end_pos:INT, ignore_case:INT, match_word:INT), INT
'Searches for the given searchtext, in characters from start_pos to end_pos.
'You can choose to select ignore_case and match_word. ignore_case=1-match_case
'Returns the position of the first found match. If there is no match, then returns -1
INT pos
INT flags

FINDTEXT MyFindtext
MyFindtext.chrg.cpMin = start_pos
MyFindtext.chrg.cpMax = end_pos
MyFindtext.lpstrText = Searchtext
flags = FR_MATCHCASE*(1-ignore_case) | FR_WHOLEWORD*match_word
pos = SENDMESSAGE(w, EM_FINDTEXT, flags, MyFindtext, ctl)

    RETURN pos
ENDSUB

aurelCB

So what is? no one of you dont know how convert this to Creative Code.
I allways mean that i'm only here wich knowlege is small...

LarryMc

With a quick glance I would say it can be converted to CBasic.

You'll just have to convert the window and control stuff from the EBasic way to the CBasic way.

Do as much as you can then post your error codes to get someone to help.

I'm working on my own programs and don't have time to convert it all for you.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

aurelCB

Ok mr.Larry you right.
I'm just curius is this posible.And here is code wich i try convert but without sucsses.
I'm not good in functions -passing by reference or passing by values.Hmmm ...
maby someone can help....

'/*
'color code in rich edit control
'ibasic pro code
'jos de jong, 2007
'*/
'Creative code---->
'Declarations
'$INCLUDE "windows.inc"
CONST WM_USER = 0x400
CONST EM_FINDTEXT = (WM_USER + 56)
TYPE CHARRANGE
def cpMin:int
def cpMax:int
ENDTYPE
TYPE FINDTEXT
    def CHARRANGE :chrg
    def lpstrText:pointer
ENDTYPE

declare applyColorSheet(dlg:DIALOG,ctl:INT)
declare applyColorLine(dlg:DIALOG,ctl:INT)
declare RTFINDTEXT( w:DIALOG,ctl:INT,Searchtext:STRING,start_pos:INT,end_pos:INT,ignore_case:INT,match_word:INT), INT
'create a list with keywords
CONST kewordCount = 9
DEF keyword[kewordCount]:STRING
keyword[0] = "IF"
keyword[1] = "THEN"
keyword[2] = "ELSE"
keyword[3] = "ENDIF"
keyword[4] = "WHILE"
keyword[5] = "ENDWHILE"
keyword[6] = "DO"
keyword[7] = "FOR"
keyword[8] = "NEXT"

'_______________________________________________________________________
DEF d1:Dialog
DIALOG d1,0,0,587,360,0x80C80080,0,"Color code demo",Handler
CONTROL d1,"RE,,7,35,570,294,0x50B010C4,1"
DOMODAL d1
END


'______________________________________________________________________________
SUB Handler
SELECT @CLASS
'---------------------------------
CASE @IDINITDIALOG
CENTERWINDOW d1
'--------------------------------
'let the rich edit control send a message when the contents have changed
mask = CONTROLCMD(d1,1,@RTGETEVENTMASK)
CONTROLCMD d1, 1, @RTSETEVENTMASK, mask | @ENMKEYEVENTS |@ENMCHANGE

SETCONTROLTEXT d1, 1, "This program can highlight keywords like- IF THEN FOR NEXT "

applyColorSheet(d1, 1)

CASE @IDCONTROL
SELECT @CONTROLID
CASE 1:'richedit
SELECT @NOTIFYCODE
CASE @ENCHANGE
'the contents of the richedit are changed
' applyColorLine(d1, 1)
ENDSELECT
ENDSELECT

ENDSELECT
RETURN
'ENDSUB



'______________________________________________________________________________
'/*
'This function adjusts the colors of all lines in the sheet
'*/
SUB applyColorSheet(dlg,ctl)
def char_start, char_end:int
def linenum, linecount:int

'hide the selection and get the current caret position
CONTROLCMD dlg, ctl, @RTHIDESEL, 1
CONTROLCMD dlg, ctl, @RTGETSELECTION, char_start, char_end

linecount = CONTROLCMD(dlg, ctl, @RTGETLINECOUNT)
FOR linenum = 0 TO linecount-1
colorize(dlg, ctl, linenum)
NEXT linenum

'restore the original caret position and show the selection again
CONTROLCMD dlg, ctl, @RTSETSELECTION, char_start, char_end
CONTROLCMD dlg, ctl, @RTHIDESEL, 0

RETURN
'ENDSUB


'______________________________________________________________________________
'/*
'This function adjusts the colors of the current line
'*/
SUB applyColorLine(dlg,ctl)
def char_start, char_end:int
def linenum:int

'hide the selection and get the current caret position
CONTROLCMD dlg, ctl, @RTHIDESEL, 1
CONTROLCMD dlg, ctl, @RTGETSELECTION, char_start, char_end

linenum = CONTROLCMD (dlg, ctl, @RTLINEFROMCHAR, char_start)
colorize(dlg, ctl, linenum)

'restore the original caret position and show the selection again
CONTROLCMD dlg, ctl, @RTSETSELECTION, char_start, char_end
CONTROLCMD dlg, ctl, @RTHIDESEL, 0

RETURN
'ENDSUB

'______________________________________________________________________________
'/*
'This function adjusts the colors of the keywords on the given linenum
'*/
SUB colorize(dlg,ctl,linenum)
def lineStart, lineLength:int
def i:int
def p, pLine:int

lineStart = CONTROLCMD (dlg, ctl, @RTCHARFROMLINE, linenum)
lineLength = CONTROLCMD (dlg, ctl, @RTGETLINELENGTH, linenum)

'uncolor the whole line, set black color
CONTROLCMD dlg, ctl, @RTSETSELECTION, lineStart, lineStart + lineLength
CONTROLCMD dlg, ctl, @RTSETSELCOLOR, RGB(0, 0, 0)

'check the keywords one by one, if they occur on this line
FOR i=0 TO kewordCount-1
p = lineStart-1
DO
p = RTFINDTEXT(dlg, ctl, keyword[i], p+1, lineStart + lineLength, True, True)
IF p >= 0
'the keyword is found at the current line. color it
CONTROLCMD dlg, ctl, @RTSETSELECTION, p, p+LEN(keyword[i])
CONTROLCMD dlg, ctl, @RTSETSELCOLOR, RGB(255, 0, 0)

''you can also add making the text uppercase and things like that...
'CONTROLCMD dlg, ctl, @RTREPLACESEL, UCASE$(keyword[i])
ENDIF
UNTIL p < 0
NEXT i

RETURN
'ENDSUB


'________________________________________________________________________
SUB RTFINDTEXT(w:DIALOG,ctl:INT,Searchtext:STRING,start_pos:INT,end_pos:INT,ignore_case:INT,match_word:INT), INT
'Searches for the given searchtext, in characters from start_pos to end_pos.
'You can choose to select ignore_case and match_word. ignore_case=1-match_case
'Returns the position of the first found match. If there is no match, then returns -1
def pos:int
def flags:int
' >>> here i recive error message
FINDTEXT MyFindtext :' variable wrong type in line 166 <<<<
MyFindtext.chrg.cpMin = start_pos
MyFindtext.chrg.cpMax = end_pos
MyFindtext.lpstrText = Searchtext
flags = FR_MATCHCASE*(1-ignore_case) | FR_WHOLEWORD*match_word
pos = SENDMESSAGE(w, EM_FINDTEXT, flags, MyFindtext, ctl)

    RETURN pos
'ENDSUB

aurelCB

Another try but still dont work ???

'-------------------------------
'color code in rich edit control
'ibasic pro code
'jos de jong, 2007
'*/
'Creative code---->
'Declarations
'$INCLUDE "windows.inc"
CONST FR_WHOLEWORD = 0x2
CONST FR_MATCHCASE = 0x4
CONST WM_USER = 0x400
CONST EM_FINDTEXT = (WM_USER + 56)
TYPE CHARRANGE
def cpMin:int
def cpMax:int
ENDTYPE
TYPE FINDTEXT
    def chrg:CHARRANGE
    def lpstrText:pointer
    'def MyFindText:string
ENDTYPE
'i add this declared functions-maby is wrong here
declare applyColorSheet(dlg:DIALOG,ctl:INT)
declare applyColorLine(dlg:DIALOG,ctl:INT)
declare RTFINDTEXT( w:DIALOG,ctl:INT,Searchtext:STRING,start_pos:INT,end_pos:INT,ignore_case:INT,match_word:INT), INT
'create a list with keywords
CONST kewordCount = 9
DEF keyword[kewordCount]:STRING
keyword[0] = "IF"
keyword[1] = "THEN"
keyword[2] = "ELSE"
keyword[3] = "ENDIF"
keyword[4] = "WHILE"
keyword[5] = "ENDWHILE"
keyword[6] = "DO"
keyword[7] = "FOR"
keyword[8] = "NEXT"

'_______________________________________________________________________
DEF d1:Dialog
DIALOG d1,0,0,587,360,0x80C80080,0,"Color code demo",Handler
CONTROL d1,"RE,,7,35,570,294,0x50B010C4,1"
DOMODAL d1
END


'______________________________________________________________________________
SUB Handler
SELECT @CLASS
'---------------------------------
CASE @IDINITDIALOG
CENTERWINDOW d1
'--------------------------------
'let the rich edit control send a message when the contents have changed
mask = CONTROLCMD(d1,1,@RTGETEVENTMASK)
CONTROLCMD d1, 1, @RTSETEVENTMASK, mask | @ENMKEYEVENTS |@ENMCHANGE

SETCONTROLTEXT d1, 1, "This program can highlight keywords like- IF THEN FOR NEXT "

applyColorSheet(d1, 1)

CASE @IDCONTROL
SELECT @CONTROLID
CASE 1:'richedit
SELECT @NOTIFYCODE
CASE @ENCHANGE
'the contents of the richedit are changed
applyColorLine(d1, 1)
ENDSELECT
ENDSELECT
ENDSELECT
RETURN

'This function adjusts the colors of all lines in the sheet
SUB applyColorSheet(dlg,ctl)
def char_start, char_end:int
def linenum, linecount:int

'hide the selection and get the current caret position
CONTROLCMD dlg, ctl, @RTHIDESEL, 1
CONTROLCMD dlg, ctl, @RTGETSELECTION, char_start, char_end

linecount = CONTROLCMD(dlg, ctl, @RTGETLINECOUNT)
FOR linenum = 0 TO linecount-1
colorize(dlg, ctl, linenum)
NEXT linenum

'restore the original caret position and show the selection again
CONTROLCMD dlg, ctl, @RTSETSELECTION, char_start, char_end
CONTROLCMD dlg, ctl, @RTHIDESEL, 0

RETURN

'This function adjusts the colors of the current line
SUB applyColorLine(dlg,ctl)
def char_start, char_end:int
def linenum:int

'hide the selection and get the current caret position
CONTROLCMD dlg, ctl, @RTHIDESEL, 1
CONTROLCMD dlg, ctl, @RTGETSELECTION, char_start, char_end

linenum = CONTROLCMD (dlg, ctl, @RTLINEFROMCHAR, char_start)
colorize(dlg, ctl, linenum)

'restore the original caret position and show the selection again
CONTROLCMD dlg, ctl, @RTSETSELECTION, char_start, char_end
CONTROLCMD dlg, ctl, @RTHIDESEL, 0

RETURN

'This function adjusts the colors of the keywords on the given linenum
SUB colorize(dlg,ctl,linenum)
def lineStart, lineLength:int
def i,ctl,linenum:int
def p, pLine:int
lineStart = CONTROLCMD (d1, 1,@RTLINEFROMCHAR, linenum)
lineLength = CONTROLCMD (d1, 1, @RTGETLINELENGTH, linenum)

'uncolor the whole line, set black color
' CONTROLCMD dlg, ctl, @RTHIDESEL, 0
CONTROLCMD d1, 1, @RTSETSELECTION, lineStart, lineStart + lineLength
CONTROLCMD d1, 1, @RTSETSELCOLOR, RGB(0, 0, 0)

'check the keywords one by one, if they occur on this line
FOR i=0 TO kewordCount-1
p = lineStart-1
DO
p = RTFINDTEXT(dlg, ctl, keyword[i], p+1, lineStart + lineLength, True, True)
IF p >= 0
'the keyword is found at the current line. color it
CONTROLCMD dlg, ctl, @RTSETSELECTION, p, p+LEN(keyword[i])
CONTROLCMD dlg, ctl, @RTSETSELCOLOR, RGB(255, 0, 0)

''you can also add making the text uppercase and things like that...
'CONTROLCMD dlg, ctl, @RTREPLACESEL, UCASE$(keyword[i])
ENDIF
UNTIL p < 0
NEXT i
RETURN

SUB RTFINDTEXT(w:DIALOG,ctl:INT,Searchtext:STRING,start_pos:INT,end_pos:INT,ignore_case:INT,match_word:INT)
'Searches for the given searchtext, in characters from start_pos to end_pos.
'You can choose to select ignore_case and match_word. ignore_case=1-match_case
'Returns the position of the first found match. If there is no match, then returns -1
def w:dialog
def start_pos, end_pos,ctl:int
def Searchtext:string
def ignore_case:INT
def match_word:INT
def pos:int
def flags:int
'>>> here i recive error message
def Myfindtext:FINDTEXT:'variable wrong type in line 166 <<<<
MyFindtext.chrg.cpMin = start_pos
MyFindtext.chrg.cpMax = end_pos
MyFindtext.lpstrText = Searchtext
flags = FR_MATCHCASE*(1-ignore_case) | FR_WHOLEWORD*match_word
    'here i recive error now-variable wrong type in line 160
pos = SENDMESSAGE(d1, EM_FINDTEXT, flags, MyFindtext, ctl)

RETURN pos


any idea or maby someone know different way?

aurelCB

Hi again...
I made few changas and i got something but still dont work properly.
I replace @RTCHARFROMLINE to @RTLINEFROMCHAR ,i know that is wrong
but how replace (convert) this comand to CB
'-------------------------------------------------------------------------------------------------
   lineStart = CONTROLCMD (d1, 1,@RTLINEFROMCHAR, linenum)
   lineLength = CONTROLCMD (d1, 1, @RTGETLINELENGTH, linenum)
'-----------------------------------------------------------------------------------------------------
Also i disable function:
RTFINDTEXT( w:DIALOG,ctl:INT,Searchtext:STRING,start_pos:INT,end_pos:INT,ignore_case:INT,match_word:INT), INT

So here is code:

'-------------------------------
'color code in rich edit control
'ibasic pro code
'jos de jong, 2007
'*/
'Creative code---->
'Declarations
'$INCLUDE "windows.inc"
CONST FR_WHOLEWORD = 0x2
CONST FR_MATCHCASE = 0x4
CONST WM_USER = 0x400
CONST EM_FINDTEXT = (WM_USER + 56)
TYPE CHARRANGE
def cpMin:int
def cpMax:int
ENDTYPE
TYPE FINDTEXT
    def chrg:CHARRANGE
    def lpstrText:pointer
    'def MyFindText:string
ENDTYPE
'i add this declared functions-maby is wrong here
declare applyColorSheet(dlg:DIALOG,ctl:INT)
declare applyColorLine(dlg:DIALOG,ctl:INT)
'declare RTFINDTEXT( w:DIALOG,ctl:INT,Searchtext:STRING,start_pos:INT,end_pos:INT,ignore_case:INT,match_word:INT), INT
'create a list with keywords
CONST kewordCount = 9
DEF keyword[kewordCount]:STRING
keyword[0] = "IF"
keyword[1] = "THEN"
keyword[2] = "ELSE"
keyword[3] = "ENDIF"
keyword[4] = "WHILE"
keyword[5] = "ENDWHILE"
keyword[6] = "DO"
keyword[7] = "FOR"
keyword[8] = "NEXT"

'_______________________________________________________________________
DEF d1:Dialog
DIALOG d1,0,0,587,360,0x80C80080,0,"Color code demo",Handler
CONTROL d1,"RE,,7,35,570,294,0x50B010C4,1"
DOMODAL d1
END


'______________________________________________________________________________
SUB Handler
SELECT @CLASS
'---------------------------------
CASE @IDINITDIALOG
CENTERWINDOW d1
SETFONT d1, "Courier New", 10, 400,0,1
'--------------------------------
'let the rich edit control send a message when the contents have changed
mask = CONTROLCMD(d1,1,@RTGETEVENTMASK)
CONTROLCMD d1, 1, @RTSETEVENTMASK, mask | @ENMKEYEVENTS |@ENMCHANGE

SETCONTROLTEXT d1, 1, "This program can highlight keywords like- IF a THEN bi FOR  nil NEXT"

applyColorSheet(d1, 1)

CASE @IDCONTROL
SELECT @CONTROLID
CASE 1:'richedit
SELECT @NOTIFYCODE
CASE @ENCHANGE
'the contents of the richedit are changed
applyColorLine(d1, 1)
ENDSELECT
ENDSELECT
ENDSELECT
RETURN

'This function adjusts the colors of all lines in the sheet
SUB applyColorSheet(dlg,ctl)
def char_start, char_end:int
def linenum, linecount:int

'hide the selection and get the current caret position
CONTROLCMD dlg, ctl, @RTHIDESEL, 1
CONTROLCMD dlg, ctl, @RTGETSELECTION, char_start, char_end

linecount = CONTROLCMD(dlg, ctl, @RTGETLINECOUNT)
FOR linenum = 0 TO linecount-1
colorize(dlg, ctl, linenum)
NEXT linenum

'restore the original caret position and show the selection again
CONTROLCMD dlg, ctl, @RTSETSELECTION, char_start, char_end
CONTROLCMD dlg, ctl, @RTHIDESEL, 0

RETURN

'This function adjusts the colors of the current line
SUB applyColorLine(dlg,ctl)
def char_start, char_end:int
def linenum:int

'hide the selection and get the current caret position
CONTROLCMD dlg, ctl, @RTHIDESEL, 1
CONTROLCMD dlg, ctl, @RTGETSELECTION, char_start, char_end

linenum = CONTROLCMD (dlg, ctl, @RTLINEFROMCHAR, char_start)
colorize(dlg, ctl, linenum)

'restore the original caret position and show the selection again
CONTROLCMD dlg, ctl, @RTSETSELECTION, char_start, char_end
CONTROLCMD dlg, ctl, @RTHIDESEL, 0

RETURN

'This function adjusts the colors of the keywords on the given linenum
SUB colorize(dlg,ctl,linenum)
def lineStart, lineLength:int
def i,ctl,linenum:int
def p, pLine:int
' i replace @rtcharfromline to @RTLINEFROMCHAR ,i know that is wrong
' but how replace (convert) this comand to CB
lineStart = CONTROLCMD (d1, 1,@RTLINEFROMCHAR, linenum)
lineLength = CONTROLCMD (d1, 1, @RTGETLINELENGTH, linenum)

'uncolor the whole line, set black color
' CONTROLCMD dlg, ctl, @RTHIDESEL, 0
CONTROLCMD d1, 1, @RTSETSELECTION, lineStart, lineStart + lineLength
CONTROLCMD d1, 1, @RTSETSELCOLOR, RGB(0, 0, 0)

'check the keywords one by one, if they occur on this line
FOR i=0 TO kewordCount-1
p = lineStart-1
DO
'p = RTFINDTEXT(dlg, ctl, keyword[i], p+1, lineStart + lineLength, True, True)
' i change previus line to :
p = CONTROLCMD (d1, 1, @RTFINDTEXT,keyword[i] , p+1,lineStart + lineLength )

IF p > 0
'the keyword is found at the current line. color it
CONTROLCMD d1, 1, @RTSETSELECTION, p, p+LEN(keyword[i])
CONTROLCMD d1, 1, @RTSETSELCOLOR, RGB(255, 0, 0)

''you can also add making the text uppercase and things like that...
'CONTROLCMD dlg, ctl, @RTREPLACESEL, UCASE$(keyword[i])
ENDIF
UNTIL p < 0
NEXT i
RETURN

SUB RTFINDTEXT(w:DIALOG,ctl:INT,Searchtext:STRING,start_pos:INT,end_pos:INT,ignore_case:INT,match_word:INT)
'Searches for the given searchtext, in characters from start_pos to end_pos.
'You can choose to select ignore_case and match_word. ignore_case=1-match_case
'Returns the position of the first found match. If there is no match, then returns -1
def w:dialog
def start_pos, end_pos,ctl:int
def Searchtext:string
def ignore_case:INT
def match_word:INT
def pos:int
def flags:int
'>>> here i recive error message
def Myfindtext:FINDTEXT:'variable wrong type in line 166 <<<<
MyFindtext.chrg.cpMin = start_pos
MyFindtext.chrg.cpMax = end_pos
MyFindtext.lpstrText = Searchtext
flags = FR_MATCHCASE*(1-ignore_case) | FR_WHOLEWORD*match_word
    'here i recive error now-variable wrong type in line 160
pos = SENDMESSAGE(d1, EM_FINDTEXT,MyFindtext,0, 1)

RETURN pos


Any sugesstion???

LarryMc

I tried to solve the problem but was unsuccessful.
I'm not familiar with IBasic Standard or CBasic since I've never used them.

Larry
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

aurelCB


aurelCB

Uh finaly works....
Simple just add two lines of code and works properly!
regards
aurel ;)

'-------------------------------
'color code in rich edit control
'ibasic pro code
'original jos de jong, 2007
'Creative code ---->>>>>>>>>>>>>>>>>>>
declare applyColorSheet(d1:DIALOG,ctl:INT)
declare applyColorLine(d1:DIALOG,ctl:INT)
'create a list with keywords
CONST kewordCount = 9
DEF keyword[kewordCount]:STRING
keyword[0] = "IF"
keyword[1] = "THEN"
keyword[2] = "ELSE"
keyword[3] = "ENDIF"
keyword[4] = "WHILE"
keyword[5] = "ENDWHILE"
keyword[6] = "DO"
keyword[7] = "FOR"
keyword[8] = "NEXT"

'_______________________________________________________________________
DEF d1:Dialog
DIALOG d1,0,0,587,360,0x80C80080,0,"Color code demo",Handler
CONTROL d1,"RE,,7,35,570,294,0x50B010C4,1"
DOMODAL d1
END
'______________________________________________________________________________
SUB Handler
SELECT @CLASS
'---------------------------------
CASE @IDINITDIALOG
CENTERWINDOW d1
SETFONT d1, "Courier New", 10, 400,0,1
'--------------------------------
'let the rich edit control send a message when the contents have changed
mask = CONTROLCMD(d1,1,@RTGETEVENTMASK)
CONTROLCMD d1, 1, @RTSETEVENTMASK, mask | @ENMKEYEVENTS |@ENMCHANGE

SETCONTROLTEXT d1, 1, "This program FOR highlight keywords like"+chr$(13)+"IF ; THEN ; FOR ; NEXT"

applyColorSheet(d1, 1)

CASE @IDCONTROL
SELECT @CONTROLID
CASE 1:'richedit
SELECT @NOTIFYCODE
CASE @ENCHANGE
'the contents of the richedit are changed
applyColorLine(d1, 1)
ENDSELECT
ENDSELECT
ENDSELECT
RETURN

'This function adjusts the colors of all lines in the sheet
SUB applyColorSheet(d1,ctl)
def char_start, char_end:int
def linenum, linecount:int

'hide the selection and get the current caret position
CONTROLCMD d1, ctl, @RTHIDESEL, 1
CONTROLCMD d1, ctl, @RTGETSELECTION, char_start, char_end

linecount = CONTROLCMD(d1, ctl, @RTGETLINECOUNT)
messagebox d1,"Linecount= "+str$(linecount),"LCount"

FOR linenum = 0 TO linecount-1
colorize(d1, ctl, linenum)
NEXT linenum

'restore the original caret position and show the selection again
CONTROLCMD d1, ctl, @RTSETSELECTION, char_start, char_end
CONTROLCMD d1, ctl, @RTHIDESEL, 0

RETURN

'This function adjusts the colors of the current line
SUB applyColorLine(d1,ctl)
def char_start, char_end:int
def linenum:int

'hide the selection and get the current caret position
CONTROLCMD d1, ctl, @RTHIDESEL, 1
CONTROLCMD d1, ctl, @RTGETSELECTION, char_start,char_end

linenum = CONTROLCMD (d1, ctl, @RTLINEFROMCHAR, char_start)
colorize(d1, ctl, linenum)

'restore the original caret position and show the selection again
CONTROLCMD d1, ctl, @RTSETSELECTION, char_start, char_end
CONTROLCMD d1, ctl, @RTHIDESEL, 0

RETURN

'This function adjusts the colors of the keywords on the given linenum
SUB colorize(d1,ctl,linenum)
def lineStart, lineLength:int
def i,ctl,linenum,char_start:int
def p, pLine:int

' but how replace (convert) this comand to CB
lineStart = CONTROLCMD (d1, 1,char_start, linenum)
lineLength = CONTROLCMD (d1, 1, @RTGETLINELENGTH,linenum)

'uncolor the whole line, set black color
' CONTROLCMD dlg, ctl, @RTHIDESEL, 0
CONTROLCMD d1, 1, @RTSETSELECTION, lineStart, lineStart + lineLength
CONTROLCMD d1, 1, @RTSETSELCOLOR, RGB(0, 0, 0)

'check the keywords one by one, if they occur on this line
FOR i=0 TO kewordCount-1
p = lineStart+1
DO
'p = RTFINDTEXT(dlg, ctl, keyword[i], p+1, lineStart + lineLength, True, True)
' i change previus line to :
p = CONTROLCMD (d1, 1, @RTFINDTEXT,keyword[i] , p+1,p+LEN(keyword[i]) )

IF p > 0
'the keyword is found at the current line. color it
CONTROLCMD d1, 1, @RTSETSELECTION, p,p+LEN(keyword[i])
CONTROLCMD d1, 1, @RTSETSELCOLOR, RGB(255, 0, 0)
ENDIF

''you can also add making the text uppercase and things like that...
'CONTROLCMD dlg, ctl, @RTREPLACESEL, UCASE$(keyword[i])

UNTIL p < 0
'next two lines solve problem------------------------------------
CONTROLCMD d1, 1, @RTSETSELECTION, p,p-LEN(keyword[i])
CONTROLCMD d1, 1, @RTSETSELCOLOR, RGB(0, 0, 0)
'----------------------------------------------------------------
NEXT i
RETURN


aurelCB

Next example present colorized text in RichEdit control
wich is created in window not in dialog.
I'm think that work better in window becose there's no flickering when you start program.
I also add just one color for specific word.
regards
Aurel :)

'Sintax color in window
'Creative code---->
'Declarations
'declare applyColorSheet(d1:DIALOG,ctl:INT)
declare applyColorLine(w1:window,ctl:INT)
'create a list with keywords
CONST kewordCount = 12
DEF keyword[kewordCount]:STRING
keyword[0] = "IF"
keyword[1] = "THEN"
keyword[2] = "ELSE"
keyword[3] = "ENDIF"
keyword[4] = "WHILE"
keyword[5] = "ENDWHILE"
keyword[6] = "TO"
keyword[7] = "FOR"
keyword[8] = "NEXT"
keyword[9] = "PRINT"
keyword[10] = "START"
keyword[11] = "SUB"

DEF w1:window
Window w1,0,0,600,400,@minbox,0,"Color code in window",main
Setwindowcolor w1,rgb(231,222,231)

run=1
Waituntil run =0
Closewindow w1
END

SUB main
SELECT @CLASS
'---------------------------------
case @idclosewindow
run=0
case @idcreate
Centerwindow w1
CONTROL w1,"RE,,7,35,570,294,0x50B010C4,1"
SETFONT w1, "Courier New", 10, 400,0,1

'let the rich edit control send a message when the contents have changed
mask = CONTROLCMD(w1,1,@RTGETEVENTMASK)
CONTROLCMD w1, 1, @RTSETEVENTMASK, mask | @ENMKEYEVENTS |@ENMCHANGE
' put text in control
SETCONTROLTEXT w1, 1, ">>>start<<< SUB open()"

CASE @IDCONTROL
SELECT @CONTROLID
CASE 1:'richedit
SELECT @NOTIFYCODE
CASE @ENCHANGE
'the contents of the richedit are changed
applyColorLine(w1,1)
ENDSELECT
ENDSELECT
ENDSELECT
RETURN

'This function adjusts the colors of the current line
SUB applyColorLine(w1,ctl)
def char_start, char_end:int
def linenum:int

'hide the selection and get the current caret position
CONTROLCMD w1, 1, @RTHIDESEL, 1
CONTROLCMD w1, 1, @RTGETSELECTION, char_start, char_end

linenum = CONTROLCMD (w1, 1, @RTLINEFROMCHAR, char_start)
colorize(w1, 1, linenum)

'restore the original caret position and show the selection again
CONTROLCMD w1, 1, @RTSETSELECTION, char_start, char_end
CONTROLCMD w1, 1, @RTHIDESEL, 0

RETURN

'This function adjusts the colors of the keywords on the given linenum
SUB colorize(w1,ctl,linenum)
def lineStart, lineLength:int
def i,ctl,linenum,char_start:int
def p, pLine:int

' but how replace (convert) this comand to CB,i use variable
lineStart = CONTROLCMD (w1, 1,char_start, linenum)
lineLength = CONTROLCMD (w1, 1, @RTGETLINELENGTH, linenum)

'uncolor the whole line, set black color
' CONTROLCMD dlg, ctl, @RTHIDESEL, 0
CONTROLCMD w1, 1, @RTSETSELECTION, lineStart, lineStart + lineLength
CONTROLCMD w1, 1, @RTSETSELCOLOR, RGB(0, 0, 0)

'check the keywords one by one, if they occur on this line
FOR i=0 TO kewordCount-1
p = lineStart-1
DO

p = CONTROLCMD (w1, 1, @RTFINDTEXT,keyword[i] , p+1,lineStart + lineLength )

IF p > 0
'the keyword is found at the current line. color it
CONTROLCMD w1, 1, @RTSETSELECTION, p, p+LEN(keyword[i])
CONTROLCMD w1, 1, @RTSETSELCOLOR, RGB(0, 0, 250)

''you can also add making the text uppercase and things like that...
'i add second color(magenta) for SUB
if keyword[i]="SUB"
CONTROLCMD w1, 1, @RTSETSELCOLOR, RGB(200, 0, 200)
'next line set every colorized keyword in upper case
CONTROLCMD w1, 1, @RTREPLACESEL, UCASE$(keyword[i])
endif
ENDIF
UNTIL p < 0

CONTROLCMD w1, 1, @RTSETSELECTION, p, p-LEN(keyword[i])
CONTROLCMD w1, 1, @RTSETSELCOLOR, RGB(0, 0, 0)
NEXT i
RETURN


aurelCB

Next step look like real code editor.
I think that would be useful for many of us.
Copy next code in editor(press button Paste ) and tell me how look?

' >>>start<<< sintax color on
Def w1:WINDOW
Window w1, 0,0,400,300, @minbox ,0,"Sintax Color",main

run=1
Waituntil run=0
Closewindow w1
End

SUB main
Select @class
   Case @idclosewindow
      run=0
Endselect
RETURN

'Sintax color in window
'Creative code---->
'Declarations
def filename,ln,printer,filter:string
def file1:FILE
def buffer[32766]:ISTRING
filter = "CBasic files|*.cba|All Files|*.*||"
'declare applyColorSheet(d1:DIALOG,ctl:INT)
declare applyColorLine(w1:window,ctl:INT)
'create a list with keywords
CONST kewordCount = 28
DEF keyword[kewordCount]:STRING
keyword[0] = " IF "
keyword[1] = " THEN "
keyword[2] = " ELSE "
keyword[3] = " ENDIF "
keyword[4] = " WHILE "
keyword[5] = " ENDWHILE "
keyword[6] = " TO "
keyword[7] = " FOR "
keyword[8] = " NEXT "
keyword[9] = " PRINT "
keyword[10] = "RETURN"
keyword[11] = "SUB"
keyword[12] = "WINDOW "
keyword[13] = ":WINDOW"
keyword[14] = "DEF "
keyword[15] = "idclosewindow"
keyword[16] = "@"
keyword[17] = "WINDOW "
keyword[18] = "CLOSEWINDOW "
keyword[19] = "CLASS"
keyword[20] = "CASE"
keyword[21] = "SELECT"
keyword[22] = "COLOR"
keyword[23] = "SINTAX"
keyword[24] = "ENDSELECT"
keyword[25] = "minbox"
keyword[26] = "WAITUNTIL"
keyword[27] = "END"

DEF w1:window
Window w1,0,0,600,400,@minbox,0,"Color code in window",main
Setwindowcolor w1,rgb(231,222,231)
'--------------------------------------------
CONTROL w1,"B,Open,11,9,70,20,0x50000001,2"
SETFONT w1, "Courier New", 10, 400,0,2
CONTROL w1,"B,Save,101,9,70,20,0x50000001,3"
SETFONT w1, "Courier New", 10, 400,0,3
CONTROL w1,"B,Copy,180,9,70,20,0x50000001,4"
SETFONT w1, "Courier New", 10, 400,0,4
CONTROL w1,"B,Paste,260,9,70,20,0x50000001,5"
SETFONT w1, "Courier New", 10, 400,0,5

'--------------------------------
run=1
Waituntil run =0
Closewindow w1
END

SUB main
SELECT @CLASS
'---------------------------------
case @idclosewindow
run=0
case @idcreate
Centerwindow w1
CONTROL w1,"RE,,7,35,570,294,0x50B010C4,1"
SETFONT w1, "Courier New", 10, 400,0,1

'let the rich edit control send a message when the contents have changed
mask = CONTROLCMD(w1,1,@RTGETEVENTMASK)
CONTROLCMD w1, 1, @RTSETEVENTMASK, mask | @ENMKEYEVENTS |@ENMCHANGE
' put text in control
SETCONTROLTEXT w1, 1, "'>>>start<<< Sintax Color"

CASE @IDCONTROL
SELECT @CONTROLID
CASE 1:'richedit
SELECT @NOTIFYCODE
CASE @ENCHANGE
'the contents of the richedit are changed
applyColorLine(w1,1)
ENDSELECT

CASE 2:'open file
doopen()
CASE 3:'save file
dosave()
CASE 4:'copy
CONTROLCMD w1,1,@RTCOPY
CASE 5:'paste
CONTROLCMD w1,1,@RTPASTE

ENDSELECT
ENDSELECT
RETURN

'This function adjusts the colors of the current line
SUB applyColorLine(w1,ctl)
def char_start, char_end:int
def linenum:int

'hide the selection and get the current caret position
CONTROLCMD w1, 1, @RTHIDESEL, 1
CONTROLCMD w1, 1, @RTGETSELECTION, char_start, char_end

linenum = CONTROLCMD (w1, 1, @RTLINEFROMCHAR, char_start)
colorize(w1, 1, linenum)

'restore the original caret position and show the selection again
CONTROLCMD w1, 1, @RTSETSELECTION, char_start, char_end
CONTROLCMD w1, 1, @RTHIDESEL, 0

RETURN

'This function adjusts the colors of the keywords on the given linenum
SUB colorize(w1,ctl,linenum)
def lineStart, lineLength:int
def i,ctl,linenum,char_start:int
def p, pLine:int

' but how replace (convert) this comand to CB,i use variable
lineStart = CONTROLCMD (w1, 1,char_start, linenum)
lineLength = CONTROLCMD (w1, 1, @RTGETLINELENGTH, linenum)

'uncolor the whole line, set black color
' CONTROLCMD dlg, ctl, @RTHIDESEL, 0
CONTROLCMD w1, 1, @RTSETSELECTION, lineStart, lineStart + lineLength
CONTROLCMD w1, 1, @RTSETSELCOLOR, RGB(0, 0, 0)

'check the keywords one by one, if they occur on this line
FOR i=0 TO kewordCount-1
p = lineStart-1
DO

p = CONTROLCMD (w1, 1, @RTFINDTEXT,keyword[i] , p+1,lineStart + lineLength )

IF p > 0
'the keyword is found at the current line. color it
CONTROLCMD w1, 1, @RTSETSELECTION, p, p+LEN(keyword[i])
CONTROLCMD w1, 1, @RTSETSELCOLOR, RGB(0, 0, 250)
'CONTROLCMD w1, 1, @RTREPLACESEL, UCASE$(keyword[i])
''you can also add making the text uppercase and things like that...
'i add second color(magenta) for SUB
If keyword[i]="SUB"
CONTROLCMD w1, 1, @RTSETSELCOLOR, RGB(200, 0, 0)
CONTROLCMD w1, 1, @RTREPLACESEL, UCASE$(keyword[i])
Endif

If keyword[i]="RETURN"
CONTROLCMD w1, 1, @RTSETSELCOLOR, RGB(200, 0, 0)
CONTROLCMD w1, 1, @RTREPLACESEL, UCASE$(keyword[i])
Endif

If keyword[i]=":WINDOW"
CONTROLCMD w1, 1, @RTSETSELCOLOR, RGB(250, 0, 0)
CONTROLCMD w1, 1, @RTREPLACESEL, UCASE$(keyword[i])
Endif

If keyword[i]="idclosewindow"
CONTROLCMD w1, 1, @RTSETSELCOLOR, RGB(180,0,180)
'CONTROLCMD w1, 1, @RTREPLACESEL, UCASE$(keyword[i])
Endif

If keyword[i]="@"
CONTROLCMD w1, 1, @RTSETSELCOLOR, RGB(180,0,180)
'CONTROLCMD w1, 1, @RTREPLACESEL, UCASE$(keyword[i])
Endif

If keyword[i]="WINDOW"
CONTROLCMD w1, 1, @RTSETSELCOLOR, RGB(0,0,0)
'CONTROLCMD w1, 1, @RTREPLACESEL, UCASE$(keyword[i])
Endif

If keyword[i]="CLASS"
CONTROLCMD w1, 1, @RTSETSELCOLOR, RGB(200,0,200)
'CONTROLCMD w1, 1, @RTREPLACESEL, UCASE$(keyword[i])
Endif

If keyword[i]="COLOR"
CONTROLCMD w1, 1, @RTSETSELCOLOR, RGB(0,140,0)
'CONTROLCMD w1, 1, @RTREPLACESEL, UCASE$(keyword[i])
Endif

If keyword[i]="SINTAX"
CONTROLCMD w1, 1, @RTSETSELCOLOR, RGB(0,140,0)
'CONTROLCMD w1, 1, @RTREPLACESEL, UCASE$(keyword[i])
Endif
If keyword[i]="minbox"
CONTROLCMD w1, 1, @RTSETSELCOLOR, RGB(180,0,180)
'CONTROLCMD w1, 1, @RTREPLACESEL, UCASE$(keyword[i])
Endif

ENDIF
UNTIL p < 0

CONTROLCMD w1, 1, @RTSETSELECTION, p, p-LEN(keyword[i])
CONTROLCMD w1, 1, @RTSETSELCOLOR, RGB(0, 0, 0)
NEXT i
RETURN
'open file------------------------------------------
SUB doopen
filename = filerequest("Load File",w1,1)
if(len(filename) > 0)
buffer = ""
if( openfile(file1,filename,"R") = 0)
do
if(read(file1,ln) = 0)
if len(buffer) < (32766-257)
buffer = buffer + ln + chr$(13) + chr$(10)
endif
endif
until eof(file1)
closefile file1
setcontroltext w1,1,buffer
endif
endif
RETURN
'save file-------------------------------------
SUB dosave
filename = filerequest("Save File",w1,0,filter,"cba")
if(len(filename) > 0)
if(openfile(file1,filename,"W") = 0)
buffer = getcontroltext(w1,1)
GOSUB RemoveCR
write file1,buffer
closefile file1
endif
endif
RETURN
'-------------
SUB RemoveCR
def pos:INT
def buffer2[32766]:ISTRING
pos = INSTR(buffer,CHR$(13))
while(pos)
if(mid$(buffer,pos,1) = CHR$(13))
buffer2 = left$(buffer,pos-1)
buffer2 = buffer2 + mid$(buffer,pos+1)
buffer = buffer2
endif
pos = INSTR(pos+1,buffer,chr$(13))
endwhile
return


What you mean?

aurelCB

Without comment??OK.
I ask myself and others is this posible make faster,without external dll. or scintila engine
i mean writte directly in Creative- maby with in line assembly ??
Any idea?
regards
aurel :)

aurelCB

Hi again...
I ask you for little help of course if you have time.
I'm not satisfied with sintax color speed and i find old IBpro code with Scintila dll.
Here is original code wich work fine on EB:

window w

declare import, xmsg alias SendMessageA( wnd:uint, msg:uint, wp:uint, lp:pointer ),int
declare import, LoadLibrary alias LoadLibraryA( lp:string ),uint
declare import, FreeLibrary( hnd:uint )

const SCE_IB_DEFAULT = 0
const SCE_IB_LINECOMMENT = 1
const SCE_IB_BLOCKCOMMENT = 2
const SCE_IB_NUMBER = 3
const SCE_IB_KEYWORD = 4
const SCE_IB_TYPE = 5
const SCE_IB_SETID = 6
const SCE_IB_PREPROCESSOR = 7
const SCE_IB_STRING = 8
const SCE_IB_OPERATOR = 9
const SCE_IB_IDENTIFIER = 10
const SCE_IB_LABEL = 11
const SCE_IB_ASM = 12

const SCLEX_IBASIC = 40

const SCI_SETLEXER = 4001
const SCI_STYLESETFORE = 2051
const SCI_STYLESETBACK = 2052
const SCI_STYLECLEARALL = 2050
const SCI_SETKEYWORDS = 4005
const SCI_STYLESETFONT = 2056
const SCI_STYLESETSIZE = 2055

openwindow( w, 0, 0, 500, 500, @CAPTION|@SYSMENU, 0, "Scintilla", &handler )
setwindowcolor w,rgb(220,220,220)
uint hlibsci, hsci
hlibsci = LoadLibrary( "SciLexer.dll" )

hsci = controlex( w, "Scintilla", "", 0, 0, 400, 400, 0, 0, 1 )

xmsg( hsci, SCI_SETLEXER, SCLEX_IBASIC, 0 )

xmsg( hsci, SCI_STYLESETFORE, SCE_IB_DEFAULT, 0 )
xmsg( hsci, SCI_STYLESETBACK, SCE_IB_DEFAULT, 0xFFFFFF )
xmsg( hsci, SCI_STYLECLEARALL, 0, 0 )

for i = 0 to 12
xmsg( hsci, SCI_STYLESETFONT, i, "Courier New" )
xmsg( hsci, SCI_STYLESETSIZE, i, 10 )
next i

xmsg( hsci, SCI_SETKEYWORDS, 0, "if endif type endtype" )
xmsg( hsci, SCI_SETKEYWORDS, 1, "window uint wincolor dialog" )
xmsg( hsci, SCI_SETKEYWORDS, 2, "@caption @sysmenu @minbox" )
xmsg( hsci, SCI_SETKEYWORDS, 3, "$include $ifdef $ifndef $endif" )

xmsg( hsci, SCI_STYLESETFORE, SCE_IB_LINECOMMENT, 0x008800 )
xmsg( hsci, SCI_STYLESETFORE, SCE_IB_BLOCKCOMMENT, 0x008800 )
xmsg( hsci, SCI_STYLESETFORE, SCE_IB_NUMBER, 0x008888 )
xmsg( hsci, SCI_STYLESETFORE, SCE_IB_KEYWORD, 0x0000FF )
xmsg( hsci, SCI_STYLESETFORE, SCE_IB_TYPE, 0xFF0000 )
xmsg( hsci, SCI_STYLESETFORE, SCE_IB_SETID, 0xFF8800 )
xmsg( hsci, SCI_STYLESETFORE, SCE_IB_PREPROCESSOR, 0x000088 )
xmsg( hsci, SCI_STYLESETFORE, SCE_IB_STRING, 0x880088 )
xmsg( hsci, SCI_STYLESETFORE, SCE_IB_OPERATOR, 0x884400 )
xmsg( hsci, SCI_STYLESETFORE, SCE_IB_IDENTIFIER, 0x000000 )
xmsg( hsci, SCI_STYLESETFORE, SCE_IB_LABEL, 0xAAAAAA )
xmsg( hsci, SCI_STYLESETFORE, SCE_IB_ASM, 0x555555 )

waituntil w.hwnd = 0
FreeLibrary( hlibsci )
end

sub handler

select @CLASS
case @IDCLOSEWINDOW
closewindow w
endselect

return
endsub


So i try convert this code to Creative but dont work.
I mean that i'm forget or miss something i realy dont know?
Maby is not posible becose CB dont support comand CONTROLEX??
I add this files in samples folder:SciLexer.dll(1.6.8.0),LexIBasic(CXXfile),scintilla.map file.

Here is my attempt:
def w:window

declare "kernel32.dll",xmsg alias SendMessageA( wnd:int, msg:int, wp:int, lp:pointer ),int
declare "kernel32.dll",LoadLibrary alias  LoadLibraryA( lp:string ),int
declare "kernel32.dll", FreeLibrary( hnd:int )

const controlex = 0x50B010C4

const SCE_IB_DEFAULT = 0
const SCE_IB_LINECOMMENT = 1
const SCE_IB_BLOCKCOMMENT = 2
const SCE_IB_NUMBER = 3
const SCE_IB_KEYWORD = 4
const SCE_IB_TYPE = 5
const SCE_IB_SETID = 6
const SCE_IB_PREPROCESSOR = 7
const SCE_IB_STRING = 8
const SCE_IB_OPERATOR = 9
const SCE_IB_IDENTIFIER = 10
const SCE_IB_LABEL = 11
const SCE_IB_ASM = 12

const SCLEX_IBASIC = 40

const SCI_SETLEXER = 4001
const SCI_STYLESETFORE = 2051
const SCI_STYLESETBACK = 2052
const SCI_STYLECLEARALL = 2050
const SCI_SETKEYWORDS = 4005
const SCI_STYLESETFONT = 2056
const SCI_STYLESETSIZE = 2055

def i:int
window w, 0, 0, 600, 480, @CAPTION|@SYSMENU, 0, "Scintilla", handler
setwindowcolor w,rgb(220,220,220)
def hlibsci, hsci:int

messagebox w,"Library Loaded : "+str$(hlibsci),"SciLib":'befor loading
hlibsci = LoadLibrary( "SciLexer.dll" )
messagebox w,"Library Loaded : "+str$(hlibsci),"SciLib":'after loading

'hsci =
control w,"RE,Scintila, 0, 0, 450, 400,0x50B010C4, 1"


'CONTROL w,"RE,,58,49,379,251,0x50B010C4,1"
'{return = } SENDMESSAGE ( window | dialog, msg, wparam, lparam {,ID} )
'''hsci=SendMessageA( wnd:int, msg:int, wp:int, lp:pointer )
'xmsg( hsci, SCI_SETLEXER, SCLEX_IBASIC, 0 )
hsci=SENDMESSAGE(w,SCI_SETLEXER, SCLEX_IBASIC, 0,1)
hsci=SENDMESSAGE (w, SCI_STYLESETFORE, SCE_IB_DEFAULT, 0 ,1)
hsci=SENDMESSAGE (w, SCI_STYLESETBACK, SCE_IB_DEFAULT, 0xFFFFFF,1 )
hsci=SENDMESSAGE (w, SCI_STYLECLEARALL, 0, 0,1)


for i = 0 to 12
hsci=SENDMESSAGE (w,SCI_STYLESETFONT, i, "Courier New",1 )
hsci=SENDMESSAGE (w, SCI_STYLESETSIZE, i, 10 ,1)
next i

hsci=SENDMESSAGE(w,SCI_SETKEYWORDS, 0, "if endif type endtype" ,1):'red
hsci=SENDMESSAGE(w, SCI_SETKEYWORDS, 1, "window setfont wincolor let ",1 ):'blue
hsci=SENDMESSAGE(w,SCI_SETKEYWORDS, 2, "@idcontrol @sysmenu @minbox",1 ):'lightblue
hsci=SENDMESSAGE(w, SCI_SETKEYWORDS, 3, "$include $ifndef $endif",1 ):'brown

hsci=SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_LINECOMMENT, 0x008800 ,1)
hsci=SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_BLOCKCOMMENT, 0x008800,1 )
hsci=SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_NUMBER, 0x008888,1)
hsci=SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_KEYWORD, 0x0000FF ,1)
hsci=SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_TYPE, 0xFF0000,1 )
hsci=SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_SETID, 0xFF8800 ,1)
hsci=SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_PREPROCESSOR, 0x000088 ,1)
hsci=SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_STRING, 0x880088 ,1)
hsci=SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_OPERATOR, 0x884400 ,1)
hsci=SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_IDENTIFIER, 0x000000 ,1)
hsci=SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_LABEL, 0xAAAAAA ,1)
hsci=SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_ASM, 0x555555 ,1)

waituntil w.hwnd = 0
FreeLibrary( hlibsci )
end

sub handler

select @CLASS
case @IDCLOSEWINDOW
closewindow w

endselect

return
'endsub


So what you mean ,what is wrong?


aurelCB

Hi where are you ....
Is it posible replace command CONTROLEX with some else or
create rich edit control from api.
I search and search but nothing usegful.
So every help will be OK :)

sapero

September 01, 2008, 03:00:19 PM #14 Last Edit: September 02, 2008, 03:39:53 AM by sapero
Hi Zlatko, you can use CreateWindowEx function:
DECLARE "user32.dll", CreateWindowExA(dwExStyle:INT, lpClassName:STRING, lpWindowName:STRING, dwStyle:INT, x:INT, y:INT, nWidth:INT, nHeight:INT, hWndParent:INT, hMenu:INT, hInstance:INT, lpParam:INT),INT
DECLARE "kernel32", GetModuleHandleA(name:INT),INT

' replace controlex with
hsci = CreateWindowExA(0, "Scintilla", "hello winapi", 0x50000000, 0,0,400,400,w,1, GetModuleHandleA(0), 0)
' WS_CHILD | WS_VISIBLE = 0x50000000


EDIT: changed POINTER to INT

aurelCB

Hi Sapero
But i now recive error message for this replaced line
" Argument wrong type on line"
in this line:
hsci = CreateWindowExA(0, "Scintilla", "hello winapi", 0x50000000, 0,0,400,400,w,1, GetModuleHandleA(0), 0)
I dont understand wich argument have wrong type?

sapero

September 02, 2008, 03:38:27 AM #16 Last Edit: September 02, 2008, 03:45:12 AM by sapero
I'm surprised, you need to change the type POINTER to INT in both imported functions. Or just define a pointer variable, set it to zero and replace zero's with it where should be a pointer.
def null:pointer
null=0

GetModuleHandleA(null)
CreateWindowEx(..., null)

Updated my post.

aurelCB

Hi Sapero i try this too but still dont work.
I find an old example by Larry Adcock called Tab.In this example i find diferent shape of
CreateWindowExA function:
declare "user32",CreateWindowExA(ex:int,class:string,name:string,style:int,x:int,y:int,x1:int,y1:int,parent:window,id:int,hinstance:int,ed:int),int
I try this and i got scintilla editor on window.Here is code:
def w:window
setid "WS_VISIBLE",&H10000000
setid "WS_CHILD",&H40000000
def null:pointer
null=0
declare "user32",CreateWindowExA(ex:int,class:string,name:string,style:int,x:int,y:int,x1:int,y1:int,parent:window,id:int,hinstance:int,ed:int),int
'DECLARE "user32.dll", CreateWindowExA(dwExStyle:INT, lpClassName:STRING, lpWindowName:STRING, dwStyle:INT, x:INT, y:INT, nWidth:INT, nHeight:INT, hWndParent:INT, hMenu:INT, hInstance:INT, lpParam:INT),INT
DECLARE "kernel32", GetModuleHandleA(name:null),INT
'  declare CreateRichControl(parent:pointer,x:int,y:int,w:int,ht:int)
'def null:pointer
'null=0
'--------------------------------------------------------------------------------------
' replace controlex with
'hsci = CreateWindowExA(0, "Scintilla", "hello winapi", 0x50000000, 0,0,400,400,w,1, GetModuleHandleA(0), 0)
' WS_CHILD | WS_VISIBLE = 0x50000000
'declare "user32",CreateWindowExA(ex:int,class:string,name:string,style:int,x:int,y:int,x1:int,y1:int,parent:window,id:int,hinstance:int,ed:int),int
declare "user32.dll",xmsg alias SendMessageA( wnd:int, message:int, wparam:int, lparam:pointer ),int
declare "kernel32",LoadLibrary alias  LoadLibraryA( lp:string ),int
declare "kernel32", FreeLibrary( hnd:int )



const SCE_IB_DEFAULT = 0
const SCE_IB_LINECOMMENT = 1
const SCE_IB_BLOCKCOMMENT = 2
const SCE_IB_NUMBER = 3
const SCE_IB_KEYWORD = 4
const SCE_IB_TYPE = 5
const SCE_IB_SETID = 6
const SCE_IB_PREPROCESSOR = 7
const SCE_IB_STRING = 8
const SCE_IB_OPERATOR = 9
const SCE_IB_IDENTIFIER = 10
const SCE_IB_LABEL = 11
const SCE_IB_ASM = 12

const SCLEX_IBASIC = 40

const SCI_SETLEXER = 4001
const SCI_STYLESETFORE = 2051
const SCI_STYLESETBACK = 2052
const SCI_STYLECLEARALL = 2050
const SCI_SETKEYWORDS = 4005
const SCI_STYLESETFONT = 2056
const SCI_STYLESETSIZE = 2055

def i:int
window w, 0, 0, 600, 480, @CAPTION|@SYSMENU, 0, "Scintilla", handler
setwindowcolor w,rgb(220,220,220)
def hlibsci, hsci:uint


hlibsci = LoadLibrary( "SciLexer.dll" )
messagebox w,"Library Loaded : "+str$(hlibsci),"SciLib":'after loading
'///original code///////////////////////////////////////////////////
'hsci = controlex( w, "Scintilla", "", 0, 0, 400, 400, 0, 0, 1 )

'// by sapero ////////////////////////////////////////////////////////
'const  WS_CHILD | WS_VISIBLE = 0x50000000
hsci=CreateWindowExA(0,"scintilla","",0x50000000,0,0,400,400,w,0,0,1)
'hsci = CreateWindowExA(0, "scintilla", "",0x50000000 ,0,0,400,400,w,0, 0)
'WS_CHILD | WS_VISIBLE = 0x50000000
'control w,"RE,Scintila, 0, 0, 450, 400,0x50B010C4, 1"
'hsci = CreateWindowExA(0, "Scintilla", "hello winapi", 0x50000000, 0,0,400,400,w,1, GetModuleHandleA(null), null)

'temp=SendMessage(hWnd,4875,0,0)
hsci=SENDMESSAGE(w,SCI_SETLEXER, SCLEX_IBASIC, 1)
hsci=SENDMESSAGE (w,SCI_STYLESETFORE, SCE_IB_DEFAULT,1 )
hsci=SENDMESSAGE (w,SCI_STYLESETBACK, SCE_IB_DEFAULT, 0xFFFFFF )
hsci=SENDMESSAGE (w,SCI_STYLECLEARALL, 0, 1)


for i = 0 to 12
hsci=SENDMESSAGE (w,SCI_STYLESETFONT, i, "Courier New" )
hsci=SENDMESSAGE (w,SCI_STYLESETSIZE, i, 10 )
next i

hsci=SENDMESSAGE(SCI_SETKEYWORDS, 0,1, "if endif type endtype" ):'red
hsci=SENDMESSAGE( SCI_SETKEYWORDS, 1,1, "window setfont wincolor let " ):'blue
hsci=SENDMESSAGE(SCI_SETKEYWORDS, 2,1, "@idcontrol @sysmenu @minbox" ):'lightblue
hsci=SENDMESSAGE( SCI_SETKEYWORDS, 3,1, "$include $ifndef $endif" ):'brown

hsci=SENDMESSAGE(SCI_STYLESETFORE, SCE_IB_LINECOMMENT, 0x008800,1 )
hsci=SENDMESSAGE(SCI_STYLESETFORE, SCE_IB_BLOCKCOMMENT, 0x008800,1 )
hsci=SENDMESSAGE(SCI_STYLESETFORE, SCE_IB_NUMBER, 0x008888,1)
hsci=SENDMESSAGE(SCI_STYLESETFORE, SCE_IB_KEYWORD, 0x0000FF,1)
hsci=SENDMESSAGE(SCI_STYLESETFORE, SCE_IB_TYPE, 0xFF0000 ,1)
hsci=SENDMESSAGE(SCI_STYLESETFORE, SCE_IB_SETID, 0xFF8800,1 )
hsci=SENDMESSAGE(SCI_STYLESETFORE, SCE_IB_PREPROCESSOR, 0x000088 ,1)
hsci=SENDMESSAGE(SCI_STYLESETFORE, SCE_IB_STRING, 0x880088,1 )
hsci=SENDMESSAGE(SCI_STYLESETFORE, SCE_IB_OPERATOR, 0x884400 ,1)
hsci=SENDMESSAGE(SCI_STYLESETFORE, SCE_IB_IDENTIFIER, 0x000000,1 )
hsci=SENDMESSAGE(SCI_STYLESETFORE, SCE_IB_LABEL, 0xAAAAAA ,1)
hsci=SENDMESSAGE(SCI_STYLESETFORE, SCE_IB_ASM, 0x555555,1 )

waituntil w.hwnd = 0
Freelibrary (hlibsci)
end

sub handler

select @CLASS
case @IDCLOSEWINDOW
closewindow w

endselect

return
'endsub
sub CreateRichControl(parent:pointer,x:int,y:int,w:int,ht:int)
def hWnd:int
declare "user32",CreateWindowExA(ex:int,class:string,name:string,style:int,x:int,y:int,x1:int,y1:int,parent:window,id:int,hinstance:int,ed:int),int
hWnd=CreateWindowExA(0,"scintilla","",&H10000000 | &H40000000,x,y,w,ht,#parent,2024+num,0,0)
clear CreateWindowExA
return hWnd


Last Sub is from larry code wich represent Tabs i change name to CreateRichControl original is
CreateTabControl((parent:pointer,x:int,y:int,w:int,ht:int)

Ok i finaly add control on window but how work with SENDMESSAGE command?
CBasic suport this shape of SendMessage :
{return = } SENDMESSAGE ( window | dialog, msg, wparam, lparam {,ID} )
i use this:
hsci=SENDMESSAGE(w,SCI_SETLEXER, SCLEX_IBASIC, 1)
if i do diferent like this:
hsci=SENDMESSAGE(w,SCI_SETLEXER, SCLEX_IBASIC,0, 1) --,i recive error message
"Control not found on line:"
I dont anderstand why,becose must be:
w=window,SCI_SETLEXER=msg,SCLEX_IBASIC=wparam,0=lparam and 1 is ID
Very confusing  ???
So my question is how send  messages to scintilla???

 

sapero

The problem is: you need to add 2024 to control ID inside CreateWindowEx:
def w:window
def null:pointer
null=0
declare "user32",CreateWindowExA(ex:int,class:string,name:string,style:int,x:int,y:int,x1:int,y1:int,parent:window,id:int,hinstance:int,ed:int),int
DECLARE "kernel32", GetExeHandle alias GetModuleHandleA(name:int),INT
declare "user32.dll",xmsg alias SendMessageA(wnd:int, message:int, wparam:int, lparam:pointer ),int
declare "kernel32", LoadLibrary alias  LoadLibraryA( lp:string ),int
declare "kernel32", FreeLibrary( hnd:int )

const SCE_IB_DEFAULT = 0
const SCE_IB_LINECOMMENT = 1
const SCE_IB_BLOCKCOMMENT = 2
const SCE_IB_NUMBER = 3
const SCE_IB_KEYWORD = 4
const SCE_IB_TYPE = 5
const SCE_IB_SETID = 6
const SCE_IB_PREPROCESSOR = 7
const SCE_IB_STRING = 8
const SCE_IB_OPERATOR = 9
const SCE_IB_IDENTIFIER = 10
const SCE_IB_LABEL = 11
const SCE_IB_ASM = 12

const SCLEX_IBASIC = 40

const SCI_SETLEXER = 4001
const SCI_STYLESETFORE = 2051
const SCI_STYLESETBACK = 2052
const SCI_STYLECLEARALL = 2050
const SCI_SETKEYWORDS = 4005
const SCI_STYLESETFONT = 2056
const SCI_STYLESETSIZE = 2055

def i:int
window w, 0, 0, 600, 480, @CAPTION|@SYSMENU, 0, "Scintilla", handler
setwindowcolor w,rgb(220,220,220)
def hlibsci, hsci:uint

const IDC_SCI = 100
const IDC_SCI_CREATE = 2024+IDC_SCI

hlibsci = LoadLibrary( "SciLexer.dll" )

hsci=CreateWindowExA(0,"scintilla","",0x50000000,0,0,400,400,w,IDC_SCI_CREATE,GetExeHandle(0),0)

SENDMESSAGE(w, SCI_SETLEXER, SCLEX_IBASIC, 1, IDC_SCI)
SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_DEFAULT,100, IDC_SCI)
SENDMESSAGE(w, SCI_STYLESETBACK, SCE_IB_DEFAULT, 0xFFFFFF, IDC_SCI)
SENDMESSAGE(w, SCI_STYLECLEARALL, 0, 1, IDC_SCI)

for i = 0 to 12
SENDMESSAGE (w, SCI_STYLESETFONT, i, "Courier New", IDC_SCI)
SENDMESSAGE (w, SCI_STYLESETSIZE, i, 10, IDC_SCI)
next i

SENDMESSAGE(w, SCI_SETKEYWORDS, 0,"if endif type endtype", IDC_SCI ):'red
SENDMESSAGE(w, SCI_SETKEYWORDS, 1,"window setfont wincolor let ", IDC_SCI ):'blue
SENDMESSAGE(w, SCI_SETKEYWORDS, 2,"@idcontrol @sysmenu @minbox", IDC_SCI ):'lightblue
SENDMESSAGE(w, SCI_SETKEYWORDS, 3,"$include $ifndef $endif", IDC_SCI ):'brown

SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_LINECOMMENT, 0x008800, IDC_SCI )
SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_BLOCKCOMMENT, 0x008800, IDC_SCI )
SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_NUMBER, 0x008888, IDC_SCI)
SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_KEYWORD, 0x0000FF, IDC_SCI)
SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_TYPE, 0xFF0000, IDC_SCI)
SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_SETID, 0xFF8800, IDC_SCI )
SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_PREPROCESSOR, 0x000088, IDC_SCI)
SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_STRING, 0x880088, IDC_SCI )
SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_OPERATOR, 0x884400, IDC_SCI)
SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_IDENTIFIER, 0x000000, IDC_SCI )
SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_LABEL, 0xAAAAAA, IDC_SCI)
SENDMESSAGE(w, SCI_STYLESETFORE, SCE_IB_ASM, 0x555555, IDC_SCI )
SetControlText w, IDC_SCI, "endtype window @minbox $include 0123 #ifstr _asm //comment"

waituntil w.hwnd = 0
Freelibrary (hlibsci)
end


sub handler
select @CLASS
case @IDCLOSEWINDOW
closewindow w
endselect
return

aurelCB

Yes you right Larry use same 2024 number in his example i miss this.
WOW finaly works ;D
Thank you very much Sapero, you are real expert ;)
regards
zlatko

aurelCB

Hi...
Just one question if you have time.
Scintilla work fine but how can i activate line numbering?
thanks advance...
zlatko

sapero

const SCI_SETMARGINWIDTHN = 2242
SENDMESSAGE(w, SCI_SETMARGINWIDTHN, 0, 40, IDC_SCI)

The zero is for margin index; SC_MARGIN_SYMBOL

aurelCB


aurelCB

Hi ...
I finaly understand that all action with scintilla.dll work with SANDMESSAGE command.
And i find scintilla command list.

Begin Const
SC_CASE_LOWER=2
SC_CASE_MIXED=0
SC_CASE_UPPER=1
SCE_B_ASM =14
SCE_B_COMMENT =1
SCE_B_CONSTANT =13
SCE_B_DATE =8
SCE_B_DEFAULT =0
SCE_B_IDENTIFIER =7
SCE_B_KEYWORD =3
SCE_B_KEYWORD2 =10
SCE_B_KEYWORD3 =11
SCE_B_KEYWORD4 =12
SCE_B_NUMBER =2
SCE_B_OPERATOR =6
SCE_B_PREPROCESSOR =5
SCE_B_STRING =4
SCE_B_STRINGEOL =9
SCI_ADDTEXT=2001
SCI_BRACEBADLIGHT=2352
SCI_BRACEHIGHLIGHT=2351
SCI_BRACEMATCH=2353
SCI_CANPASTE=2173
SCI_CANREDO=2016
SCI_CANUNDO=2174
SCI_CLEAR=2180
SCI_CLEARALL=2004
SCI_COLOURISE=4003
SCI_COPY=2178
SCI_CUT=2177
SCI_EMPTYUNDOBUFFER=2175
SCI_FINDTEXT=2150
SCI_GETCARETLINEBACK=2097
SCI_GETCARETLINEVISIBLE=2095
SCI_GETCHARAT=2007
SCI_GETCOLUMN=2129
SCI_GETCURRENTPOS=2008
SCI_GETINDENT=2123
SCI_GETINDENTATIONGUIDES=2133
SCI_GETLENGTH=2006
SCI_GETLEXER=4002
SCI_GETLINECOUNT=2154
SCI_GETLINEINDENTATION=2127
SCI_GETMARGINWIDTHN=2243
SCI_GETMODIFY=2159
SCI_GETSEARCHFLAGS =2199
SCI_GETSELECTIONEND=2145
SCI_GETSELECTIONSTART=2143
SCI_GETTARGETEND= 2193
SCI_GETTARGETSTART= 2191
SCI_GETTEXT=2182
SCI_GETTEXTLENGTH=2183
SCI_GETUSETABS=2125
SCI_GETVIEWEOL=2355
SCI_GETVIEWWS=2020
SCI_GETWRAPMODE=2269
SCI_GETZOOM=2374
SCI_GOTOLINE=2024
SCI_GOTOPOS=2025
SCI_INSERTTEXT=2003
SCI_LINEFROMPOSITION=2166
SCI_PASTE=2179
SCI_POSITIONFROMLINE=2167
SCI_REDO=2011
SCI_REPLACETARGET= 2194
SCI_REPLACETARGETRE =2195
SCI_SCROLLCARET=2169
SCI_SEARCHINTARGET= 2197
SCI_SELECTALL=2013
SCI_SETCARETFORE=2069
SCI_SETCARETLINEBACK=2098
SCI_SETCARETLINEVISIBLE=2096
SCI_SETCURRENTPOS=2141
SCI_SETINDENT=2122
SCI_SETINDENTATIONGUIDES=2132
SCI_SETKEYWORDS=4005
SCI_SETLEXER=4001
SCI_SETLEXERLANGUAGE=4006
SCI_SETLINEINDENTATION=2126
SCI_SETMARGINWIDTHN=2242
SCI_SETPROPERTY=4004
SCI_SETSAVEPOINT=2014
SCI_SETSEARCHFLAGS =2198
SCI_SETSELBACK=2068
SCI_SETSELECTIONEND=2144
SCI_SETSELECTIONSTART=2142
SCI_SETSELFORE=2067
SCI_SETTARGETEND= 2192
SCI_SETTARGETSTART= 2190
SCI_SETTEXT=2181
SCI_SETUSETABS=2124
SCI_SETVIEWEOL=2356
SCI_SETVIEWWS=2021
SCI_SETWRAPMODE=2268
SCI_SETZOOM=2373
SCI_STYLESETBACK =2052
SCI_STYLESETBOLD =2053
SCI_STYLESETCASE=2060
SCI_STYLESETFONT =2056
SCI_STYLESETFORE =2051
SCI_STYLESETITALIC =2054
SCI_STYLESETSIZE =2055
SCI_TARGETFROMSELECTION=2287
SCI_UNDO=2176
SCI_USEPOPUP=2371
SCI_ZOOMIN=2333
SCI_ZOOMOUT=2334
SCLEX_CPP=3
SCLEX_HTML=4
SCLEX_NULL=1
SCLEX_PERL=6
SCLEX_PYTHON=2
SCLEX_SQL=7
SCLEX_VB=8
SCLEX_XML=5
SCN_UPDATEUI=2007
End Const


For example is this command SCI_GETLINECOUNT=2154 same as  @RTGETLINECOUNT
and wich command replace @RTGETLINE ?
I only found here SCI_GETTEXT=2182 ?
Without this two commands i can do anything what i need.
thanks advance
zlatko
zlatko

sapero

Zlatko, download my headers pak, install it to any directory (like temp) and search in /include/scintilla.inc for SCI_GETLINE, or anything you need. There is also scilexer include.
To replace selection or insert text, use the @EDREPLACESEL / EM_REPLACESEL edit control command. Some edit commands are still supported in scintilla.