How to set SpinGadget() Font Size?

Windows specific forum
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

How to set SpinGadget() Font Size?

Post by IdeasVacuum »

No matter what size the SpinGadget is, the default tiny system font is used. Is there a way to set the font size?
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
RSBasic
Moderator
Moderator
Posts: 1228
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: How to set SpinGadget() Font Size?

Post by RSBasic »

SetGadgetFont()

\\Edit:
Get standard font and set font size (only windows):

Code: Select all

EnableExplicit

;Get standard font
Define NONCLIENTMETRICS.NONCLIENTMETRICS
NONCLIENTMETRICS\cbSize = SizeOf(NONCLIENTMETRICS)
SystemParametersInfo_(#SPI_GETNONCLIENTMETRICS, 0, @NONCLIENTMETRICS, 0)

If OpenWindow(0, 0, 0, 500, 400, "Window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  SpinGadget(1, 10, 10, 100, 50, 0, 100, #PB_Spin_Numeric)
  SetGadgetState(1, 50)
  
  LoadFont(1, PeekS(@NONCLIENTMETRICS\lfCaptionFont\lfFaceName[0]), 20)
  SetGadgetFont(1, FontID(1))
  
  Repeat
    Select WaitWindowEvent()
      Case #PB_Event_CloseWindow
        End
    EndSelect
  ForEver
EndIf
Image
Image
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: How to set SpinGadget() Font Size?

Post by IdeasVacuum »

...Thanks RSBasic, that's a lot easier than I was expecting! Would make a good addition to your WinAPI Library :wink:
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4997
Joined: Sun Apr 12, 2009 6:27 am

Re: How to set SpinGadget() Font Size?

Post by RASHAD »

Code: Select all

  If OpenWindow(0, 0, 0, 140, 70, "SpinGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  SpinGadget     (0, 20, 20, 90, 35, 0, 1000)
  fID = GetGadgetFont(0)
  GetObject_(fID, SizeOf(LOGFONT), @lf.LOGFONT)
  LoadFont(0,PeekS(@lf\lfFaceName),16)
  SetGadgetFont(0,FontID(0))

    SetGadgetState (0, 5) : SetGadgetText(0, "5")   ; set initial value
    Repeat
      Event = WaitWindowEvent()
      If Event = #PB_Event_Gadget
        If EventGadget() = 0
          SetGadgetText(0, Str(GetGadgetState(0)))
        EndIf
      EndIf
    Until Event = #PB_Event_CloseWindow
  EndIf
Egypt my love
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: How to set SpinGadget() Font Size?

Post by IdeasVacuum »

Hi Rashad, that method works perfectly too. :mrgreen:
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Post Reply