Page 1 of 1

How to set SpinGadget() Font Size?

Posted: Fri Feb 05, 2016 1:22 pm
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?

Re: How to set SpinGadget() Font Size?

Posted: Fri Feb 05, 2016 1:34 pm
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

Re: How to set SpinGadget() Font Size?

Posted: Fri Feb 05, 2016 4:21 pm
by IdeasVacuum
...Thanks RSBasic, that's a lot easier than I was expecting! Would make a good addition to your WinAPI Library :wink:

Re: How to set SpinGadget() Font Size?

Posted: Fri Feb 05, 2016 8:32 pm
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

Re: How to set SpinGadget() Font Size?

Posted: Sat Feb 06, 2016 1:39 am
by IdeasVacuum
Hi Rashad, that method works perfectly too. :mrgreen: