April 25, 2024, 05:15:00 PM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Setting a control colour when using CreateWindowEx

Started by Andy, October 17, 2019, 03:51:21 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

Hi,

Well I've have either asked this before or completely forgotten it.

When I create a static like this:

CONTROL w1,@STATIC,"Processes",10,10,190,25,@CTEDITLEFT,20 I can set the colour of the text and background i.e.

SETCONTROLCOLOR w1,20,RGB(160,138,0),RGB(0,0,0) - that's fine.

But when I create a static control using CreateWindowEx, SETCONTROLCOLOR does not work.

Any suggestions please?

Thanks,
Andy.

 
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Andy

I've got around it by just making the statics in the normal IWB way - but still it's an interesting question.

Think sub classing comes into it somewhere.

Andy.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

LarryMc

When you create a control with the CONTROL command most of its properties are initialized and stored using the windows SetPropA command.
The foreground and background color variables are initialized using these commands by IWB:
IF win.hwnd
hControl = GetDlgItem(win.hwnd,id)
IF hControl
SetPropA(hControl,"FGRND",fg)
SetPropA(hControl,"BGRND",bg)
hBrush = GetPropA(hControl,"BBRUSH")
SetPropA(hControl,"BBRUSH",CreateSolidBrush(bg))
IF hBrush THEN DeleteObject(hBrush)
InvalidateRect(hControl,0,1)
ENDIF
ENDIF
I believe these property names are unique to IWB so when you create a control/window with CreateWindowEx it doesn't create any properties by these names.
So when you try to use any SET/GET IWB commands that use the properties nothing happens.

Hope that answers your question.

LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library