Set TextGadget Font Color
Posted: Sat Jan 17, 2004 9:21 pm
Code updated For 5.20+ (same As SetGadgetColor())
Code: Select all
; Many thanks to Danilo for the base code
;My contribution is getting the background color
;so the text background always "looks" transparent!
Global TextGadgetBackground, TextGadgetForeground
color= GetSysColor_(#COLOR_3DFACE) ; get color of the background
TextGadgetBackground = CreateSolidBrush_(color)
TextGadgetForeground = RGB($FF,$FF,$00)
Procedure WinProc(hWnd,Msg,wParam,lParam)
If Msg = #WM_CTLCOLORSTATIC And lParam = GadgetID(0)
SetBkMode_(wParam,#TRANSPARENT)
SetTextColor_(wParam,TextGadgetForeground)
ProcedureReturn TextGadgetBackground
Else
ProcedureReturn #PB_ProcessPureBasicEvents
EndIf
EndProcedure
OpenWindow(0,0,0,200,25,"TextGadget Color",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
SetWindowCallback(@WinProc())
TextGadget(0,5,5,190,15,"This text is colored")
Repeat:Until WaitWindowEvent()=#PB_Event_CloseWindow
DeleteObject_(TextGadgetBackground)