Old 25th June 2005, 22:59   #1
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
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
Attached Files
File Type: zip iocolors.zip (1.7 KB, 144 views)
Afrow UK is offline   Reply With Quote
Old 25th June 2005, 23:14   #2
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
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.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 25th June 2005, 23:24   #3
jsbach
Junior Member
 
Join Date: Feb 2005
Location: Italy
Posts: 42
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...."
jsbach is offline   Reply With Quote
Old 25th June 2005, 23:33   #4
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
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 is offline   Reply With Quote
Old 27th June 2005, 09:44   #5
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
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
Afrow UK is offline   Reply With Quote
Old 27th June 2005, 12:23   #6
onad
Senior Member
 
onad's Avatar
 
Join Date: Dec 2004
Location: Turkey
Posts: 447
Question

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.

"Just do it"
onad is offline   Reply With Quote
Old 28th June 2005, 08:34   #7
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Righto, I'll put an archive page up.
I'll check that bug again and submit a bug report.

-Stu
Afrow UK is offline   Reply With Quote
Old 21st May 2012, 22:23   #8
Brummelchen
Major Dude
 
Join Date: May 2003
Posts: 681
Quote:
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.
Brummelchen is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump