Date: 02-16-2022
Return to Index
created by gbSnippets
'On startup, or at any time during execution, you may want to know what
'the settings are for all of the properties for each style. This snippet
'provides that information
'Primary Code:
'These are the style attributes. Scintilla GET functions will be used to
'retrieve their current values:
' FontName Underline FG/BG Colors
' Size CharacterSet FillToEOL
' Bold Visible Changeable
' Italic Case Hotspot
'The messages used to get the style attributes are:
SendMessage hSci, %SCI_StyleGetFont, i,StrPTR(FontName)
iFontSize = SendMessage(hSci, %SCI_StyleGetSize, i,0)
iBold = SendMessage(hSci, %SCI_StyleGetBold, i,0)
iItalic = SendMessage(hSci, %SCI_StyleGetItalic, i,0)
iUnderline = SendMessage(hSci, %SCI_StyleGetUnderline, i,0)
iCharSet = SendMessage(hSci, %SCI_StyleGetCharacterSet, i,0)
iVisible = SendMessage(hSci, %SCI_StyleGetVisible, i,0)
ICase = SendMessage(hSci, %SCI_StyleGetHotSpot, i,0) '1-lower 2-upper 0-normal
iFillToEOL = SendMessage(hSci, %SCI_StyleGetEOLFilled, i,0)
iChangeable = SendMessage(hSci, %SCI_StyleGetChangeable, i,0)
iHotSpot = SendMessage(hSci, %SCI_StyleGetHotSpot, i,0)
iFore = SendMessage(hSci, %SCI_StyleGetFore, i,0)
iBack = SendMessage(hSci, %SCI_StyleGetBack, i,0)
'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
Global hDlg, hSci, hLib As DWord
Function PBMain() As Long
hLib = LoadLibrary("SCILEXER.DLL")
Dialog New Pixels, 0, "Scintilla Example",300,300,750,600, %WS_OverlappedWindow To hDlg
Control Add "Scintilla", hDlg, %ID_Sci, "", 10,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_Size
Control Set Size hDlg, %ID_Sci, Lo(Word, CB.lParam)-20, 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, extra, title, fontname As String
Local iFontSize, iBold, iItalic, iUnderline, iVisible, iCase As Long
Local iFillToEOL, iChangeable, iHotSpot, iCharSet, iFore, iBack, i As Long
SendMessage hSci, %SCI_SetMarginWidthN, 0, 20
title = $CrLf + "Style Size BIU Char Vis Case Fill Chang Hot FG BG Name" + $CrLf
SendMessage hSci, %SCI_AppendText, Len(title), StrPTR(title)
For i = 0 To 38
fontname = String$(32," ")
SendMessage hSci, %SCI_StyleGetFont, i,StrPTR(FontName)
Replace Chr$(0) With "" in Fontname
iFontSize = SendMessage(hSci, %SCI_StyleGetSize, i,0)
iBold = SendMessage(hSci, %SCI_StyleGetBold, i,0)
iItalic = SendMessage(hSci, %SCI_StyleGetItalic, i,0)
iUnderline = SendMessage(hSci, %SCI_StyleGetUnderline, i,0)
iCharSet = SendMessage(hSci, %SCI_StyleGetCharacterSet, i,0)
iVisible = SendMessage(hSci, %SCI_StyleGetVisible, i,0)
ICase = SendMessage(hSci, %SCI_StyleGetHotSpot, i,0) '1-lower 2-upper 0-normal
iFillToEOL = SendMessage(hSci, %SCI_StyleGetEOLFilled, i,0)
iChangeable = SendMessage(hSci, %SCI_StyleGetChangeable, i,0)
iHotSpot = SendMessage(hSci, %SCI_StyleGetHotSpot, i,0)
iFore = SendMessage(hSci, %SCI_StyleGetFore, i,0)
iBack = SendMessage(hSci, %SCI_StyleGetBack, i,0)
extra = ""
Select Case i
Case 32: extra = "Style_Default"
Case 33: extra = "Style_LineNumber"
Case 34: extra = "Style_BraceLight"
Case 35: extra = "Style_BraceBad"
Case 36: extra = "Style_ControlChar"
Case 37: extra = "Style_IndentGuide"
Case 38: extra = "Style_CallTip"
End Select
txt = txt + Format$(i, " 00")
txt = txt + Format$(IFontSize," 0")
txt = txt + Format$(IBold," 0")
txt = txt + Format$(IItalic,"0")
txt = txt + Format$(Iunderline,"0")
txt = txt + Format$(Icharset," 0")
txt = txt + Format$(iVisible," 0")
txt = txt + Format$(ICase," 0")
txt = txt + Format$(Ifilltoeol," 0")
txt = txt + Format$(Ichangeable," 0")
txt = txt + Format$(Ihotspot," 0")
txt = txt + Format$(Ifore," 00000000 ")
txt = txt + Format$(Iback," 00000000 ")
txt = txt + " " + FontName + " " + extra + $CrLf
Next i
SendMessage hSci, %SCI_AppendText, Len(txt), StrPTR(txt)
Control Set Focus hDlg, %ID_Sci 'focus
End Sub
'gbs_00676
'Date: 03-10-2012
http://www.garybeene.com/sw/gbsnippets.htm