Archive: Bug with MUI, WinXP Luna and SetCtlColors?


Bug with MUI, WinXP Luna and SetCtlColors?
I have a problem with WinXP, Luna, NSIS 2.12, ModernUI. I added some custom controls to welcome page and changed the background to transparent in custom show function using setCtlColors. This does not work correct with Luna (modern WinXP Gui).

The following code works with WinXP Luna AND classic:


Function showWelcomePage
Push $0
GetDlgItem $0 $MUI_HWND 1203
SetCtlColors $0 "000080" "${MUI_BGCOLOR}"
GetDlgItem $0 $MUI_HWND 1204
SetCtlColors $0 "" "${MUI_BGCOLOR}"
Pop $0
FunctionEnd


The following code works only with classic. The last ctl (highest ID) will get black background (unreadable). This occurs directly after starting the Installer. Similar problem with uninstaller welcome page.


Function showWelcomePage
Push $0
GetDlgItem $0 $MUI_HWND 1203
SetCtlColors $0 "000080" "transparent"
GetDlgItem $0 $MUI_HWND 1204
SetCtlColors $0 "" "transparent"
Pop $0
FunctionEnd


Of course those controls get added in preWelcomePage. 1204 is a checkbox and 1203 is a web link.

ioSpecial.ini


[Settings]
Rect=1044
NumFields=5
RTL=0
NextButtonText=
CancelEnabled=
[Field 1]
Type=bitmap
Left=0
Right=109
Top=0
Bottom=193
Flags=RESIZETOFIT
Text=C:\Temp\nstB0.tmp\modern-wizard.bmp
HWND=1704972
[Field 2]
Type=label
Left=120
Right=315
Top=10
Text=Welcome...
Bottom=38
HWND=853212
[Field 3]
Type=label
Left=120
Right=315
Top=45
Bottom=140
Text=bla bla
HWND=853208
[Field 4]
Type=Link
Left=120
Right=315
Top=175
Bottom=185
State=http://nsis.sf.net
Text=Web page
HWND=1508514
[Field 5]
Type=Checkbox
Text=Express-Installation
Flags=NOTIFY
State=0
Left=120
Right=315
Top=145
Bottom=155
HWND=787520

How did you get it to show up in classic? The only difference I can think of between MUI and classic is that the MUI sets the background of the entire dialog to white. In the MUI, setting the background back to nothing still showed up the check box as black.

Anyway, back to the original issue, I think I saw it once. I think it's a problem with the BUTTON class lack of support for transparent backgrounds. It probably has something to do with this quote from MSDN's page about WM_CTLCOLORBTN:

However, only owner-drawn buttons respond to the parent window processing this message.
NSIS itself doesn't handle SetCtlColors differently for different window classes.

Sorry, I did mean "Windows GUI classic mode" (Windows XP user style "classic" which is similar to Win2000 GUI).

So: WinXP classic style works correct, Luna NOT. Same installer.

What is quite weird: My welcome page has two custom controls. In the code above always the last (highest ID, 1204) control is black, it is always a checkbox. I'm quite sure I had also both controls black during my experiments, probably due to not changing the foreground color of the link control (1203).


A checkbox also uses the BUTTON window class, so I don't think it has anything to do with their order.


Maybe it is the fact that 1204 is the last control in ioSpecial.ini


Can you attach a complete example? I don't want to create it again.


Never mind, created one on my own. I've added another checkbox, set its background to transparent and both of them were black. I've also tried changing their field numbers to 1 and 2, still black. It's not related to its location in the INI file.


Sorry. I don't have a full script for this one. (funny order :-))


Why not use ${MUI_BGCOLOR}?


In fact, I do (now). So the issue is somewhat academic. But it is not "transparent". If it is not working correctly, "transparent" should be removed (at least from NSIS help) or this issue should be mentioned. I never noticed this quite some time because I use classic Windows GUI.


The "transparent" switch is working. It only fails for check boxes on XP for some weird unknown reason which seems to be unrelated to NSIS. I've tried some other applications, and they all exhibit this behavior.

I'll update the help file.


If one really want to solve it, there is always the hard way :(

IDEA:

1)Get position x,y, h,w of Checkbox text. (x = Full + Checkbox width)
2)Create a memorybitmap and copy the background for moriginal background source to this canvas
3) Write the text on the memorybitmap canvas
4) Copy the memorybitmap to the dialogcanvas on the correct position.

Just an idea, I know it is a lot of work, but that is sometimes the case with developing...