Change font size of gadgets

Just starting out? Need help? Post your questions and find answers here.
Lebostein
Addict
Addict
Posts: 807
Joined: Fri Jun 11, 2004 7:07 am

Change font size of gadgets

Post by Lebostein »

How I can change the font size only? I can reset the default gadget font for all gadgets. But I do not want to change the default font of the operating system (I don't know which font is used), only the size...
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: Change font size of gadgets

Post by RSBasic »

Code: Select all

EnableExplicit

Define NONCLIENTMETRICS.NONCLIENTMETRICS
NONCLIENTMETRICS\cbSize = SizeOf(NONCLIENTMETRICS)
SystemParametersInfo_(#SPI_GETNONCLIENTMETRICS, 0, NONCLIENTMETRICS, 0)

LoadFont(1, PeekS(@NONCLIENTMETRICS\lfCaptionFont\lfFaceName[0]), 20)

If OpenWindow(0, 0, 0, 500, 400, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  SetGadgetFont(#PB_Default, FontID(1))
  
  ButtonGadget(1, 10, 10, 100, 30, "Button")
  TextGadget(2, 10, 50, 100, 30, "Hello")
  CheckBoxGadget(3, 10, 100, 100, 30, "Checkbox")
  
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_Gadget
        Select EventGadget()
          Case 1
            
        EndSelect
      Case #PB_Event_CloseWindow
        End
    EndSelect
  ForEver
EndIf
I hope lfCaptionFont is the right one.
Image
Image
User avatar
chi
Addict
Addict
Posts: 1034
Joined: Sat May 05, 2007 5:31 pm
Location: Linz, Austria

Re: Change font size of gadgets

Post by chi »

Windows only

Code: Select all

LoadFont(0, "MS Shell Dlg", 8)
SetGadgetFont(#PB_Default, FontID(0))

OpenWindow(0, 0, 0, 320, 200, "", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)

ButtonGadget(0, 10, 10, 100, 30, "Button")
TextGadget(1, 10, 50, 100, 30, "Hello")
CheckBoxGadget(2, 10, 100, 100, 30, "Checkbox")

While WaitWindowEvent() <> #PB_Event_CloseWindow : Wend

Code: Select all

GetObject_(GetStockObject_(#DEFAULT_GUI_FONT), SizeOf(LOGFONT), @lf.LOGFONT)
Debug PeekS(@lf\lfFaceName[0])
Et cetera is my worst enemy
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4659
Joined: Sun Apr 12, 2009 6:27 am

Re: Change font size of gadgets

Post by RASHAD »

Code: Select all

FID = GetGadgetFont(#PB_Default)
fnt.LOGFONT    
GetObject_(FID,SizeOf(fnt),@fnt)
FName$ =  PeekS(@fnt\lfFaceName[0])
LoadFont(0,Fname$,18)
SetGadgetFont(#PB_Default,FontID(0))

If OpenWindow(0, 0, 0, 500, 400, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  ButtonGadget(1, 10, 10, 100, 30, "Button")
  TextGadget(2, 10, 50, 100, 30, "Hello")
  CheckBoxGadget(3, 10, 100, 140, 30, "Checkbox") 
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_Gadget
        Select EventGadget()
          Case 1
           
        EndSelect
      Case #PB_Event_CloseWindow
        End
    EndSelect
  ForEver
EndIf
Egypt my love
Lebostein
Addict
Addict
Posts: 807
Joined: Fri Jun 11, 2004 7:07 am

Re: Change font size of gadgets

Post by Lebostein »

Thanks, it seems there is no solution with PB possible, only for Windows with API functions...
Post Reply