TrackBarGadget Backcolor!
Posted: Sun Feb 15, 2009 8:32 pm
I created a TrackBarGadget in my Red colored window. But the trackbar gadget stands out coz its back color has not changed.
http://www.purebasic.com
https://www.purebasic.fr/english/
Code: Select all
Procedure WinCallback(hwnd, msg, wParam, lParam)
result = #PB_ProcessPureBasicEvents
Select msg
Case #WM_CTLCOLORSTATIC
result = GetGadgetData(1)
EndSelect
ProcedureReturn result
EndProcedure
If OpenWindow(0, 0, 0, 320, 240, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
SetWindowColor(0, #Red)
TrackBarGadget(1, 10, 10, 300, 30, 0, 25, #PB_TrackBar_Ticks)
winColor = GetWindowColor(0)
If winColor <> -1
hBrush = CreateSolidBrush_(winColor)
If hBrush
SetGadgetData(1, hBrush)
SetWindowCallback(@WinCallback())
EndIf
EndIf
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
If hBrush
DeleteObject_(hBrush)
EndIf
EndIf
Code: Select all
Procedure WinCallback(hwnd, msg, wParam, lParam)
result = #PB_ProcessPureBasicEvents
Select msg
Case #WM_CTLCOLORSTATIC
result = GetGadgetData(1)
EndSelect
ProcedureReturn result
EndProcedure
If OpenWindow(0, 0, 0, 320, 100, "", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
TrackBarGadget(1, 10, 10, 300, 30, 0, 25, #PB_TrackBar_Ticks)
TextGadget(2, 10, 50, 300, 25, "This background isn't red")
col = #Red
hBrush = CreateSolidBrush_(col)
If hBrush
SetWindowColor(0, col)
SetGadgetData(1, hBrush)
SetWindowCallback(@WinCallback())
SetGadgetColor(2, #PB_Gadget_BackColor, col)
EndIf
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
If hBrush
DeleteObject_(hBrush)
EndIf
EndIf
Code: Select all
Procedure WinCallback(hWnd, Msg, wParam, lParam)
Result = #PB_ProcessPureBasicEvents
Select Msg
Case #WM_CTLCOLORSTATIC
Select lParam
Case GadgetID(1)
Result = GetGadgetData(1)
EndSelect
EndSelect
ProcedureReturn Result
EndProcedureCode: Select all
Procedure WinCallback(hWnd, Msg, wParam, lParam)
Result = #PB_ProcessPureBasicEvents
Select Msg
Case #WM_CTLCOLORSTATIC
SetBkMode_(wParam, #TRANSPARENT)
ProcedureReturn GetGadgetData(1)
EndSelect
ProcedureReturn Result
EndProcedure