#WM_CTLCOLORSTATIC with EasyVENT

Just starting out? Need help? Post your questions and find answers here.
Konne
Enthusiast
Enthusiast
Posts: 434
Joined: Thu May 12, 2005 9:15 pm

#WM_CTLCOLORSTATIC with EasyVENT

Post 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?
Apart from that Mrs Lincoln, how was the show?
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Re: #WM_CTLCOLORSTATIC with EasyVENT

Post 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.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
Konne
Enthusiast
Enthusiast
Posts: 434
Joined: Thu May 12, 2005 9:15 pm

Post by Konne »

Apart from that Mrs Lincoln, how was the show?
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post 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.
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post 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() ?
I may look like a mule, but I'm not a complete ass.
Konne
Enthusiast
Enthusiast
Posts: 434
Joined: Thu May 12, 2005 9:15 pm

Post by Konne »

First Thx.
Because SetGadgetcolor doesn't work for disabled Gadgets.
Apart from that Mrs Lincoln, how was the show?
gnozal
PureBasic Expert
PureBasic Expert
Posts: 4229
Joined: Sat Apr 26, 2003 8:27 am
Location: Strasbourg / France
Contact:

Post by gnozal »

Konne wrote:First Thx.
Because SetGadgetcolor doesn't work for disabled Gadgets.
PureCOLOR_SetGadgetColor() works :wink:
For free libraries and tools, visit my web site (also home of jaPBe V3 and PureFORM).
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Konne wrote:First Thx.
Because SetGadgetcolor doesn't work for disabled Gadgets.
Ah, didn't know that. :)
I may look like a mule, but I'm not a complete ass.
Post Reply