How to set SpinGadget() Font Size?
Posted: Fri Feb 05, 2016 1:22 pm
No matter what size the SpinGadget is, the default tiny system font is used. Is there a way to set the font size?
http://www.purebasic.com
https://www.purebasic.fr/english/
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
EndIfCode: 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