' Empty GUI script created on 05-21-2011 19:54:23 by (ThinAIR)
' Empty GUI script created on 05-19-2011 08:41:54 by largo_winch (ThinAIR)
Uses "ui","console"
'#INCLUDE "%APP_INCLUDEPATH%\scintillalw.inc"
#INCLUDE "scintillalw.inc"
%SCLEX_THINBASIC = 510
%ID_Sci = 2000 : %ID_Sci2 = 2001
%ID_Button = 2002 : %ID_Button2 = 2003
%ID_TEXT = 2004 : %ID_TEXT2 = 2005
Global hDlg, hSci, hSci2 As DWord
Declare Function LoadLibrary Lib "KERNEL32.DLL" Alias "LoadLibraryA" (lpLibFileName As Asciiz) As Long
Declare Function FreeLibrary Lib "KERNEL32.DLL" Alias "FreeLibrary" (ByVal hLibModule As DWord) As Long
'-------------------------> Main Dialog -------------------------------------------->
Function TBMain() As Long
Local hLib As DWord
hLib = LoadLibrary("SCILEXER.DLL")
Dialog New Pixels, 0, "Scintilla GetText+SetText Example",200,200,600,440, %WS_OVERLAPPEDWINDOW To hDlg
Control Add Button, hDlg, %ID_Button, "result1", 10,10,60,20
Control Add Button, hDlg, %ID_Button2, "result2", 300,10,60,20
Control Add "Scintilla", hDlg, %ID_Sci, "", 10,50,280,280, %WS_CHILD Or %WS_VISIBLE
Control Add "Scintilla", hDlg, %ID_Sci2, "", 310,50,280,280, %WS_CHILD Or %WS_VISIBLE
Control Handle hDlg, %ID_Sci To hSci
Control Handle hDlg, %ID_Sci2 To hSci2
Dialog Show Modal hDlg Call DlgProc
End Function
'---------------------------------> CALLBACK FUNCTIONS --------------------------->
CallBack Function DlgProc() As Long
Local txt As String, buffer As String
Local hLib As DWord, nLen As Long, v As Long
Select Case CBMSG
Case %WM_INITDIALOG
StartSci
Case %WM_COMMAND
If CBCTL = %ID_Button Then
nLen = SendMessage(hSci, %SCI_GETTEXTLENGTH, 0, 0)
MsgBox 0, "characters lenght: "+Str$(nLen) 'ok :)
'------------------------------------------------> ?
'Buffer = IIf$(nLen + 1,%TRUE,%TRUE)
Buffer = TrimFull$(nLen+99999)',%TRUE,%TRUE)
'------------------------------------------------> ?
'not ok: I need here a NUMERIC EXPRESSION
SendMessage(hSci, %SCI_GETTEXT, Len(Buffer), StrPtr(Buffer))
'SendMessage (hSci2, %SCI_SETTEXT, 0, StrPtr(Buffer))
SendMessage (hSci, %SCI_SetMarginWidthN, 0, 20)
MsgBox 0, buffer 'only for testpurpose to see the typed in text (in messagebox)!
End If
If CBCTL = %ID_Button2 Then
nLen = SendMessage(hSci2, %SCI_GETTEXTLENGTH, 0, 0)
MsgBox 0, "characters lenght: "+Str$(nLen) 'ok :)
BUFFER = TrimFull$(nLen+9999999)'buffer
'Buffer = IIf$(nLen + 1,%TRUE,%TRUE) '? 'not ok: I need here a NUMERIC EXPRESSION
SendMessage hSci2, %SCI_GETTEXT, Len(Buffer),StrPtr(buffer)
SendMessage hSci2, %SCI_SetMarginWidthN, 0, 20
MsgBox 0, buffer
End If
Case %WM_DESTROY
If hSci2 Then FreeLibrary hSci2
End Select
End Function
Sub StartSci()
Local bufferli, strKeyWords As String, iResult As Long
strKeyWords = "case if else end select then msgbox thinbasic values vertex super euro"
bufferli =" 'Enter some new values here"+$CRLF+_
""+$CRLF+_
" sin(25) + cos(24.25) + tan(22) if nothing else color "+$CRLF+_
" case 20.0 if 34.0 else 255.25 "+$CRLF+_
" end 56.30 select 40.2 then 88.24 vertex 1.0 " +$CRLF+_
" case 24.0 + ""yes!"" and end 24.45 ""gone"", " +$CRLF+_
"super oil petrol for 1.59 euro" + $NUL+$CRLF
SendMessage hSci, %SCI_STYLESETFORE, %SCE_B_KEYWORD, Rgb(0, 0, 255)
SendMessage hSci, %SCI_STYLESETFORE, %SCE_B_STRING, Rgb(255, 0, 255)
SendMessage hSci, %SCI_STYLESETFORE, %SCE_B_NUMBER,Rgb(192,100,0)
SendMessage hSci, %SCI_SETLEXER, %SCLEX_PowerBASIC, 0 '%SCLEX_ThinBASIC
SendMessage hSci, %SCI_SETKEYWORDS, 0, StrPtr(strKeyWords)
SendMessage hSci, %SCI_SetText, 0, StrPtr(bufferli)
SendMessage hSci, %SCI_SetMarginWidthN, 0, 20
End Sub
bye, largo
Bookmarks