IonicWind Software

IWBasic => General Questions => Topic started by: Andy on October 17, 2019, 03:51:21 AM

Title: Setting a control colour when using CreateWindowEx
Post by: Andy on October 17, 2019, 03:51:21 AM
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.

 
Title: Re: Setting a control colour when using CreateWindowEx
Post by: Andy on October 17, 2019, 04:50:42 AM
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.
Title: Re: Setting a control colour when using CreateWindowEx
Post by: LarryMc on October 17, 2019, 07:12:55 AM
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.