Hi community,
I am looking for a solution to get a message, for a callback routine, after change the text cursor position in an editor gadget with mouse or keyboard. I want to analyze the character format (e.g. font, color, style) of the actual text cursor position, but what is the right way to get the text cursor change event? Thanks for tips.
Stefan
Message when change text cursor position in editor gadget
- Stefan Schnell
- User

- Posts: 85
- Joined: Wed May 07, 2003 2:53 pm
- Location: Germany - Oberirsen
- Contact:
Re: Message when change text cursor position in editor gadge
[OT reply] Where have I seen your name before???
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
"PureBasic won't be object oriented, period" - Fred.
- Stefan Schnell
- User

- Posts: 85
- Joined: Wed May 07, 2003 2:53 pm
- Location: Germany - Oberirsen
- Contact:
Hi PB,
>Where have I seen your name before???
I do not know, maybe here in forum with a question
A longer time ago I have a question about an error for a migration from PB 3.8 to 3.9, but I solve the problem, so that is the only thing. Hope it is a good souvenir on my name.
Stefan
P.S. The problem was the call of a callback routine, PB 3.8 allows to create callback without any window, PB 3.9 do not (and it is the better way).
>Where have I seen your name before???
I do not know, maybe here in forum with a question
A longer time ago I have a question about an error for a migration from PB 3.8 to 3.9, but I solve the problem, so that is the only thing. Hope it is a good souvenir on my name.
Stefan
P.S. The problem was the call of a callback routine, PB 3.8 allows to create callback without any window, PB 3.9 do not (and it is the better way).
How about somethong like this:
Code: Select all
#SCF_ALL = $4
#CFM_BOLD = $1
#CFM_CHARSET = $8000000
#CFM_COLOR = $40000000
#CFM_DISABLED = $2000
#CFM_FACE = $20000000
#CFM_ITALIC = $2
#CFM_OFFSET = $10000000
#CFM_PROTECTED = $10
#CFM_SIZE = $80000000
#CFM_STRIKEOUT = $8
#CFM_UNDERLINE = $4
#CFE_AUTOCOLOR = $40000000
#CFE_BOLD = $1
#CFE_DISABLED = #CFM_DISABLED
#CFE_ITALIC = $2
#CFE_STRIKEOUT = $8
#CFE_UNDERLINE = $4
#CFE_PROTECTED = $10
; --> Structure for EditorGadget formatting info
ecf.CHARFORMAT
Global ecf
Procedure myWindowCallback(hWnd, msg, wParam, lParam)
result = #PB_ProcessPureBasicEvents
Select msg
Case #WM_NOTIFY
*pnmhdr.NMHDR = lParam
If *pnmhdr\hwndFrom = GadgetID(0) And *pnmhdr\code = #EN_SELCHANGE
ecf\cbSize = SizeOf(CHARFORMAT)
SendMessage_(*pnmhdr\hwndFrom, #EM_GETCHARFORMAT, #SCF_SELECTION, @ecf)
color$ = Str(ecf\crTextColor)
size$ = Str(ecf\yHeight/20)
effext$ = ""
If ecf\dwEffects & #CFE_AUTOCOLOR : effect$ + "Autocolor " : EndIf
If ecf\dwEffects & #CFE_BOLD : effect$ + "Bold " : EndIf
If ecf\dwEffects & #CFE_DISABLED : effect$ + "Disabled " : EndIf
If ecf\dwEffects & #CFE_ITALIC : effect$ + "Italic " : EndIf
If ecf\dwEffects & #CFE_STRIKEOUT : effect$ + "Strikeout " : EndIf
If ecf\dwEffects & #CFE_UNDERLINE : effect$ + "Underline " : EndIf
If ecf\dwEffects & #CFE_PROTECTED : effect$ + "Protected " : EndIf
StatusBarText(0, 0, "Color: " + color$)
StatusBarText(0, 1, "Effect: " + effect$)
StatusBarText(0, 2, "Size: " + size$)
EndIf
EndSelect
ProcedureReturn result
EndProcedure
ecf\cbSize = SizeOf(CHARFORMAT)
If OpenWindow(0, 0, 0, 500, 150, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "EditorGadget Info") And CreateGadgetList(WindowID(0))
CreateStatusBar(0, WindowID())
AddStatusBarField(100)
AddStatusBarField(300)
AddStatusBarField(100)
StatusBarText(0, 0, "Color: ")
StatusBarText(0, 1, "Effects: ")
StatusBarText(0, 2, "Size: ")
EditorGadget (0, 0, 0, 500, 125)
; --> Set event mask for EditorGadget so we can catch selection changes
SendMessage_(GadgetID(0), #EM_SETEVENTMASK, 0, #ENM_SELCHANGE)
; --> Set our formatting mask
ecf\dwMask = #CFM_SIZE | #CFM_ITALIC | #CFM_COLOR | #CFM_BOLD | #CFM_STRIKEOUT
; --> Format line 0
ecf\crTextColor = RGB(255, 0, 0)
ecf\dwEffects = #CFE_ITALIC
ecf\yHeight = 10*20 ; twips
SendMessage_(GadgetID(0), #EM_SETCHARFORMAT, #SCF_SELECTION, ecf)
AddGadgetItem(0, 0, "Line 0")
; --> Format line 1
ecf\crTextColor = RGB(0, 255, 0)
ecf\dwEffects = #CFE_BOLD | #CFE_ITALIC
ecf\yHeight = 14*20 ; twips
SendMessage_(GadgetID(0), #EM_SETCHARFORMAT, #SCF_SELECTION, ecf)
AddGadgetItem(0, 1, "Line 1")
; --> Format line 2
ecf\crTextColor = RGB(0, 0, 255)
ecf\dwEffects = #CFE_BOLD | #CFE_ITALIC | #CFE_STRIKEOUT
ecf\yHeight = 18*20 ; twips
SendMessage_(GadgetID(0), #EM_SETCHARFORMAT, #SCF_SELECTION, ecf)
AddGadgetItem(0, 2, "Line 2")
; --> Set window callback to catch #EN_SELCHANGE
SetWindowCallback(@myWindowCallback())
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
EndIf
End
What goes around comes around.
PB 5.21 LTS (x86) - Windows 8.1
PB 5.21 LTS (x86) - Windows 8.1
- Stefan Schnell
- User

- Posts: 85
- Joined: Wed May 07, 2003 2:53 pm
- Location: Germany - Oberirsen
- Contact:
