It is currently Wed Oct 23, 2019 6:54 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Read Font
PostPosted: Tue Jun 21, 2005 7:08 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Thu May 12, 2005 9:15 pm
Posts: 434
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Read Font
PostPosted: Sat Dec 08, 2018 7:25 am 
Offline
Addict
Addict

Joined: Mon Feb 16, 2015 2:49 pm
Posts: 1897
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:

Code:
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Read Font
PostPosted: Sat Dec 08, 2018 8:39 am 
Offline
PureBasic Protozoa
PureBasic Protozoa
User avatar

Joined: Fri Apr 25, 2003 3:08 pm
Posts: 4493
Location: Not Sydney!!! (Bad water, no goats)
Quote:
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:


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 will take a look unless someone finds it first.

_________________
Amateur Radio, D-STAR/VK3HAF


Top
 Profile  
Reply with quote  
 Post subject: Re: Read Font
PostPosted: Sat Dec 08, 2018 9:39 am 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Apr 12, 2009 6:27 am
Posts: 3429
Hi Fang
Hi Dude

Code:
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Read Font
PostPosted: Sat Dec 08, 2018 9:59 am 
Offline
Addict
Addict

Joined: Mon Feb 16, 2015 2:49 pm
Posts: 1897
Thank you, Rashad. :) I made my own standalone procedures from your code:

Code:
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


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 14 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye