Date: 02-16-2022
Return to Index
created by gbSnippets
'By default line wrapping is off. When turned on, lines are broken after space or tab
'characters or between runs of different styles. The horizontal scroll bar does not
'appear with wrap mode is on.
'Wrap Options
' - visual flag at end of wrapped line and/or at beginning of next line
' - positioning of visual flags next to text or boundaries of window
' - indentation of wrapped sublines
'Primary code:
'Add line wrapping, with options
SendMessage hSci, %SCI_SetWrapMode, %SC_Wrap_Word, 0 'line wrapping ON
SendMessage hSci, %SCI_SetWrapVisualFlags, %SC_WRAPVISUALFLAG_START, 0 'put flags at start of wrapped lines
SendMessage hSci, %SCI_SetWrapVisualFlagsLocation, %SC_WrapVisualFlagLoc_Start_By_Text, 0 'put flag next to wrapped text
SendMessage hSci, %SCI_SetWrapStartIndent, 5, 0 'indent wrapped lines by 5 characters
'Remove line wrapping
SendMessage hSci, %SCI_SetWrapMode, %SC_Wrap_None, 0 'line wrapping OFF
'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, "PushA", 10,10,70,20, %WS_Child Or %WS_Visible
Control Add Button, hDlg, %ID_BtnB, "PushB", 10,40,70,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 = "Sometimes there can be only one person who wants what I want. "
txt = txt + "But there are those who cannot want what I want." + $CrLf
txt = txt + "If I wanted all of the things that are available to those who"
txt = txt + "want things, then my cup would runneth over!" + Chr$(0)
SendMessage hSci, %SCI_SetText, 0, StrPTR(txt)
SendMessage hSci, %SCI_SetMarginWidthN, 0, 20
End Sub
Sub TestA
SendMessage hSci, %SCI_SetWrapMode, %SC_Wrap_Word, 0 'line wrapping ON
SendMessage hSci, %SCI_SetWrapVisualFlags, %SC_WRAPVISUALFLAG_START, 0 'put flags at start of wrapped lines
SendMessage hSci, %SCI_SetWrapVisualFlagsLocation, %SC_WrapVisualFlagLoc_Start_By_Text, 0 'put flag next to wrapped text
SendMessage hSci, %SCI_SetWrapStartIndent, 5, 0 'indent wrapped lines by 5 characters
End Sub
Sub TestB
SendMessage hSci, %SCI_SetWrapMode, %SC_Wrap_None, 0 'line wrapping OFF
End Sub
'gbs_00655
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm