Hello,
I've got a very big problem.
How can I read the Font or Size or Color from a text in an editorgadget?
Is it possible to mark a letter and read the informations?
Please help me.
thx
sencerlly your Konne
Read Font
Re: Read Font
I've got a similar problem today.
I have an EditorGadget, and if I hold Ctrl and scroll the mouse wheel, the font size changes. How can I get the font size of the EditorGadget, but while the user is changing its size with Ctrl+MouseWheel, so when my app restarts it can show the font in the same size again?
Thanks to Fangbeast, I found some code to get the EditorGadget font size from here:
viewtopic.php?p=456182#p456182
But when I try to work it into my mousewheel action, it doesn't update with the scrolling:
I have an EditorGadget, and if I hold Ctrl and scroll the mouse wheel, the font size changes. How can I get the font size of the EditorGadget, but while the user is changing its size with Ctrl+MouseWheel, so when my app restarts it can show the font in the same size again?
Thanks to Fangbeast, I found some code to get the EditorGadget font size from here:
viewtopic.php?p=456182#p456182
But when I try to work it into my mousewheel action, it doesn't update with the scrolling:
Code: Select all
Procedure GetEditorFontSize(gad)
format.CHARFORMAT2\cbSize=SizeOf(CHARFORMAT2)
SendMessage_(GadgetID(gad),#EM_GETCHARFORMAT,#SCF_ALL,@format)
fs=Round(format\yHeight/20,#PB_Round_Nearest)
ProcedureReturn fs
EndProcedure
randomsize=Random(25,10)
OpenWindow(0,200,200,600,200,"test",#PB_Window_SystemMenu)
EditorGadget(0,10,10,580,150)
SetGadgetText(0,"Use Ctrl+MouseWheel here to change font size")
SetGadgetFont(0,LoadFont(0,"Arial",randomsize))
TextGadget(1,10,170,580,20,"Initial font size: "+Str(GetEditorFontSize(0)))
SetActiveGadget(0)
Repeat
ev=WaitWindowEvent(1)
If ev=#WM_MOUSEWHEEL
SetGadgetText(1,"Font size: "+Str(GetEditorFontSize(0))) ; Doesn't show new size?
EndIf
Until ev=#PB_Event_CloseWindow
- Fangbeast
- PureBasic Protozoa
- Posts: 4749
- Joined: Fri Apr 25, 2003 3:08 pm
- Location: Not Sydney!!! (Bad water, no goats)
Re: Read Font
It's not my code. And I seem to remember that I had to do a SendMessage_ to tell the editorgadget to send messages back to the user as events were occurring. Will see if I can remember where I put it but I suspect I used it in my NotePiddle project.I have an EditorGadget, and if I hold Ctrl and scroll the mouse wheel, the font size changes. How can I get the font size of the EditorGadget, but while the user is changing its size with Ctrl+MouseWheel, so when my app restarts it can show the font in the same size again?
Thanks to Fangbeast, I found some code to get the EditorGadget font size from here:
viewtopic.php?p=456182#p456182
But when I try to work it into my mousewheel action, it doesn't update with the scrolling:
I will take a look unless someone finds it first.
Amateur Radio, D-STAR/VK3HAF
Re: Read Font
Hi Fang
Hi Dude
Hi Dude
Code: Select all
OpenWindow(0,200,200,600,200,"test",#PB_Window_SystemMenu)
eg=EditorGadget(0,10,10,580,150)
SetGadgetText(0,"Use Ctrl+MouseWheel here to change font size")
TextGadget(1,10,170,580,20,"")
SetActiveGadget(0)
format.CHARFORMAT2\cbSize=SizeOf(CHARFORMAT2)
SendMessage_(eg,#EM_GETCHARFORMAT,#SCF_ALL,@format)
fs.f=Round(format\yHeight/20,#PB_Round_Nearest)
SetGadgetText(1,"Font size: "+Str(fs))
Repeat
ev=WaitWindowEvent()
If ev=#WM_MOUSEWHEEL
SendMessage_(eg, #EM_GETZOOM, @Numerator, @Denominator)
If Numerator > 0
SetGadgetText(1,"Font size: "+Str(Round(fs*Numerator/100,#PB_Round_Nearest)))
EndIf
EndIf
Until ev=#PB_Event_CloseWindow
Egypt my love
Re: Read Font
Thank you, Rashad. I made my own standalone procedures from your code:
Code: Select all
Procedure EditorFontSize(gad)
format.CHARFORMAT2\cbSize=SizeOf(CHARFORMAT2)
SendMessage_(GadgetID(gad),#EM_GETCHARFORMAT,#SCF_ALL,@format)
ProcedureReturn Round(format\yHeight/20,#PB_Round_Nearest)
EndProcedure
Procedure EditorFontSizeAfterZoom(gad)
SendMessage_(GadgetID(gad),#EM_GETZOOM,@num,@den)
ProcedureReturn Round(EditorFontSize(gad)*num/100,#PB_Round_Nearest)
EndProcedure
OpenWindow(0,200,200,600,200,"test",#PB_Window_SystemMenu)
EditorGadget(0,10,10,580,150)
SetGadgetText(0,"Use Ctrl+MouseWheel here to change font size")
TextGadget(1,10,170,580,20,"Initial font size: "+Str(EditorFontSize(0)))
SetActiveGadget(0)
Repeat
ev=WaitWindowEvent()
If ev=#WM_MOUSEWHEEL
SetGadgetText(1,"New font size: "+Str(EditorFontSizeAfterZoom(0)))
EndIf
Until ev=#PB_Event_CloseWindow