- NSIS Discussion
- Issue with SetCtlColors
Archive: Issue with SetCtlColors
Afrow UK
25th June 2005 22:59 UTC
Issue with SetCtlColors
This is probably just me, but SetCtlColors doesn't seem to work properly anymore (unless this has always been a problem).
I'm trying to set the colour of a control on an InstallOptions page in the page's Leave function. Everything else works (like EnableWindow and SendMessage) but if I try using SetCtlColors on it, nothing happens. This may also explain why someone in another recent topic couldn't get SetCtlColors to work on one of the 111 dialog labels (Banner).
This is the script (it's an example script I'm making for someone... I'm sure you can guess who ;) )
-Stu
kichik
25th June 2005 23:14 UTC
SetCtlColors doesn't update the control, you have to do that manually using UpdateWindow, RedrawWindow or some other Windows API.
SetCtlColors doesn't work on 111, because 111 doesn't support it.
jsbach
25th June 2005 23:24 UTC
msjournal
not sure this MS journal article may help (it's quite old).
http://www.microsoft.com/msj/archive/S1DCC.aspx
and this (better):
http://www.developeriq.com/articles/...p?id=186&cid=1
Found searching "WM_CTLCOLOR problem".
Abstract:
..."In Windows, there are no simple properties for setting the foreground and background colors of an edit control (or any other dialog control). In Visual Basic, you can simply write,
Edit1.BackColor = Yellow
Edit1.ForeColor = Red
but behind the scenes, Visual Basic goes through a lot of rigamarole to make this work. The mechanics for setting the color of a Windows control require handling the special message WM_CTLCOLOR, which Windows sends when it's about to paint a control. I won't go into a detailed explanation here, as this topic is covered in the Win32" documentation for WM_CTLCOLOR and numerous articles in MSDN (including some of my own, probably). I'll just give you the quick recap for edit controls. To set the color of an edit control, you must first handle WM_CTLCOLOR and check for the code CTLCOLOR_EDIT, in which case you must return the brush you want to use for the background. Second, you must call SetBkColor and SetTextColor on the HDC that Windows passes as part of the WM_CTLCOLOR message. If you think all this is strange, you're in good company...."
Afrow UK
25th June 2005 23:33 UTC
Right thanks guys. I remember you already mentioned that kichik when I had the same problem a while ago (just had forgotten!)
Can anyone show me how to call UpdateWindow in the right way?
I've found that hiding the label and showing it again seems to update it too, but it seems a bit cheap (but then again, you don't need to use the System plugin).
-Stu
Afrow UK
27th June 2005 09:44 UTC
I've found a small bug which I felt could go in here rather than create a new topic.
If you do:
FindFirst $R0 $R1 "$EXEDIR\*.tx"
and say you've got files with .txt entension, those files are found! Is this a bug?
-Stu
onad
27th June 2005 12:23 UTC
Hi Afro UK, the subject above really should go somewere else ;) I almost missed the trick of hiding and unhiding to redraw the labels. I have(had?) problems if I make the labels transparent and move to the previous screen, the lables do not refresh correcly, this tip just might solve my problem, will try and report back with a full example.
Afrow UK
28th June 2005 08:34 UTC
Righto, I'll put an archive page up.
I'll check that bug again and submit a bug report.
-Stu
Brummelchen
21st May 2012 22:23 UTC
Can anyone show me how to call UpdateWindow in the right way?
any news on this?
i have similar issue here in a leave function - unless i define a background color,
but this will probably only here with standard colors - "transparent" leaves
always a shadow and i cannot turn off for 100% text with empty text.