Date: 02-16-2022
Return to Index
created by gbSnippets
'The shape of the Scintilla cursor changes automatically, depending
'on where it is located, margin or text area. You can also change it
'by code to one of two shapes - normal (auto-changing) and wait (hourglass).
'Primary Code:
'Use one of these messages to control the cursor shape:
SendMessage hSci, %SCI_SetCursor, 4, 0 'wait (4=wait)
SendMessage hSci, %SCI_SetCursor, -1, 0 'normal (1=normal)
'Compilable Example: (Jose Includes)
#Compiler PBWin 9, PBWin 10
#Compile EXE
#Dim All
%Unicode=1
#Include "Win32API.inc"
#Include "scintilla_gb.inc"
%ID_Sci = 1000 : %ID_BtnA = 1001 : %ID_BtnB = 1002
Global hDlg, hSci, hLib As DWord
Function PBMain() As Long
hLib = LoadLibrary("SCILEXER.DLL")
Dialog New Pixels, 0, "Scintilla Example",300,300,300,150, %WS_OverlappedWindow To hDlg
Control Add Button, hDlg, %ID_BtnA, "Wait Cursor", 10,10,80,20, %WS_Child Or %WS_Visible
Control Add Button, hDlg, %ID_BtnB, "Normal Cursor", 10,40,80,20, %WS_Child Or %WS_Visible
Control Add "Scintilla", hDlg, %ID_Sci, "", 100,10,180,130, %WS_Child Or %WS_Visible
Control Handle hDlg, %ID_Sci To hSci 'get handle to Scintilla window
Dialog Show Modal hDlg Call DlgProc
End Function
CallBack Function DlgProc() As Long
Local txt As String
txt = "Select Case var$ 'first line" + $CrLf + "End Select 'last line" + Chr$(0)
Select Case CB.Msg
Case %WM_InitDialog
InitializeScintilla
PostMessage hSci, %SCI_SetSel, 0,0 'unselect initially
Case %WM_Command
Select Case CB.Ctl
Case %ID_BtnA : TestA
Case %ID_BtnB : TestB
End Select
Case %WM_Size
Control Set Size hDlg, %ID_Sci, Lo(Word, CB.lParam)-110, Hi(Word, CB.lParam)-20
Case %WM_Destroy
If hLib Then FreeLibrary hLib 'free the Scintilla library
End Select
End Function
Sub InitializeScintilla
Local txt As String
txt = "If x = 2 Then" + $CrLf + " 'do nothing" + $Crlf
txt = txt + "Else" + $crlf + " x = 0" + $crlf + "End If" + Chr$(0)
SendMessage hSci, %SCI_SetText, 0, StrPTR(txt)
SendMessage hSci, %SCI_SetMarginWidthN, 0, 20
End Sub
Sub TestA
SendMessage hSci, %SCI_SetCursor, 4, 0 'wait
End Sub
Sub TestB
SendMessage hSci, %SCI_SetCursor, -1, 0 'normal
End Sub
'gbs_00631
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm