Thanks to Sparkie and Xombie for providing the original code upon which this procedure is derived.

Here's my procedure that works after checking the rest of this thread for problems.
Code: Select all
Procedure SetGadgetFontStyle(gad,bold,italic,underline,strikeout)
font=SendMessage_(GadgetID(gad),#WM_GETFONT,0,0) : GetObject_(font,SizeOf(LOGFONT),lg.LOGFONT)
If bold=1 : lg\lfWeight=#FW_BOLD : EndIf : lg\lfItalic=italic : lg\lfUnderline=underline : lg\lfStrikeOut=strikeout
font=CreateFontIndirect_(lg) : SendMessage_(GadgetID(gad),#WM_SETFONT,font,1)
EndProcedure
If OpenWindow(0,300,250,300,200,"test",#PB_Window_SystemMenu)
FrameGadget(1,10,10,200,150,"This will be italic") : SetGadgetFontStyle(1,0,1,0,0)
ButtonGadget(2,30,50,120,25,"And this is bold") : SetGadgetFontStyle(2,1,0,0,0)
TextGadget(3,30,100,120,25,"And this is a mix!") : SetGadgetFontStyle(3,1,1,1,1)
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf