Page 1 of 1
#WM_CTLCOLORSTATIC with EasyVENT
Posted: Wed Feb 07, 2007 11:18 am
by Konne
Hi,
Does someone know how I can change the Background of an disabled Stringgadget with EasyVENT?
The Message for that is #WM_CTLCOLORSTATIC but it just doesn'T arrive in the CallBackFunction when using, #OnUnhandledWinMessage.
Can someone help me please?
Re: #WM_CTLCOLORSTATIC with EasyVENT
Posted: Wed Feb 07, 2007 12:29 pm
by gnozal
Konne wrote:Hi,
Does someone know how I can change the Background of an disabled Stringgadget with EasyVENT?
The Message for that is #WM_CTLCOLORSTATIC but it just doesn'T arrive in the CallBackFunction when using, #OnUnhandledWinMessage.
Can someone help me please?
For a StringGadget it's #WM_CTLCOLOREDIT.
Posted: Wed Feb 07, 2007 1:28 pm
by Konne
Posted: Wed Feb 07, 2007 2:21 pm
by gnozal
You are right, sorry.
I never noticed that because I handle all the #WM_CTLCOLOR* messages with the same code.
No problem to get the #WM_CTLCOLORSTATIC message for a disabled StringGadget in PureCOLOR, but I use subclassing. I don't know about EasyVENT.
Posted: Thu Feb 08, 2007 11:27 am
by srod
@Konne, your problem is that #WM_CTLCOLORSTATIC is sent to the parent window and so you must handle the main window #OnUnhandledWinMessage event.
The following demonstrates how to use EasyVENT's #OnUnhandledWinMessage message to colour a static control.
Code: Select all
;EasyVENT demonstration program - general.
;*********************************************************************************
;DEMONSTRATES #OnUnhandledWinMessage, by colouring a static control.
;*********************************************************************************
;ESSENTIAL INCLUDE.
;*********************************************************************************
XIncludeFile "EasyVENT.pbi"
;*********************************************************************************
Global GadgetBackground, GadgetForeground
GadgetBackground = CreateSolidBrush_(#Blue)
GadgetForeground = #Red
Declare.l StaticProc(*sender.PB_Sender)
Define Event.l
OpenWindow(0, 100, 100, 600, 600, "Colour static control.", #PB_Window_SystemMenu |#PB_Window_MinimizeGadget|#PB_Window_MaximizeGadget| #PB_Window_ScreenCentered)
CreateGadgetList(WindowID(0))
TextGadget(1, 5, 15, 120, 20, "Text gadget")
;Set event handlers.
;We are interested in #WM_CTLCOLORSTATIC, which is sent to the parent window. Hence we
;set a handler for the main window.
SetEventHandler(WindowID(0), #OnUnhandledWinMessage, @StaticProc())
;Force a recolouring of the text gadget.
InvalidateRect_(GadgetID(1),0,1)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
End
;*********************************************************************************
; EVENT HANDLERS
;*********************************************************************************
Procedure.l staticProc(*sender.PB_Sender)
Protected result=#PB_ProcessPureBasicEvents
If *sender\uMsg=#WM_CTLCOLORSTATIC And *sender\lParam=GadgetID(1)
SetBkMode_(*sender\wParam,#TRANSPARENT)
SetTextColor_(*sender\wParam,GadgetForeground)
result = GadgetBackground
EndIf
ProcedureReturn result
EndProcedure
I hope it helps.
*EDIT: why not simply use SetGadgetColor() ?
Posted: Thu Feb 08, 2007 3:06 pm
by Konne
First Thx.
Because SetGadgetcolor doesn't work for disabled Gadgets.
Posted: Thu Feb 08, 2007 3:10 pm
by gnozal
Konne wrote:First Thx.
Because SetGadgetcolor doesn't work for disabled Gadgets.
PureCOLOR_SetGadgetColor() works

Posted: Thu Feb 08, 2007 3:31 pm
by srod
Konne wrote:First Thx.
Because SetGadgetcolor doesn't work for disabled Gadgets.
Ah, didn't know that.
