Page 1 of 1

Set TextGadget Font Color

Posted: Sat Jan 17, 2004 9:21 pm
by Num3
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) 

Re: Set TextGadget Font Color

Posted: Sun Jan 18, 2004 7:20 am
by PB
Cool -- thanks! :)

Now all I need to do is figure out how to change the text colour on a
ButtonGadget... hopefully it can be done by modifying your code a bit.