Archive: InstallOptions: colored labels


InstallOptions: colored labels
Hi,

Here is a change to InstallOptions which allows colored text labels.

I am developing a custom welcome page with white text on a relatively dark background image. The TxtColor attribute is working fine for the links, however I need white text for some labels as well.

So ... I poked around in InstallerOptions.cpp. Most of the work seems to be done. Controls store the text color in the hImage member of the field, but there is no code to change the text color for labels. I made the following change, which seems to work for me.
Around line 754, replace the final switch case with:



case WM_CTLCOLORSTATIC:
case WM_CTLCOLOREDIT:
case WM_CTLCOLORDLG:
case WM_CTLCOLORBTN:
case WM_CTLCOLORLISTBOX:
{
BOOL brush = (BOOL)GetWindowLong((HWND)lParam, GWL_USERDATA);
if (brush)
{
UINT id = (UINT) GetWindowLong( (HWND)lParam, GWL_ID );
UINT nIdx = ::FindControlIdx( id );
if ( nIdx != -1 )
{
SetTextColor((HDC)wParam,(COLORREF)pFields[nIdx].hImage);
}
SetBkMode((HDC)wParam, TRANSPARENT);
return brush;
}
}



Now I modify the label in the .ini file:


[Field 1]
Type=Label
TxtColor=0xFFFFFF
Left=202
Right=322
Top=152
Bottom=190



And make sure to set the background color for the label to transparent:

GetDlgItem $DLGITEM $HWND_WELCOME_DIALOG 1200
SetBkColor $DLGITEM transparent


And it seems to work.

If there is a better way to do this, or if a similar change is in the works by the developers, please let me know.

Thanks,

- Guido

Support for changing text foreground colors will be added soon (for the whole NSIS UI, not only IO).


ah, cool, have been waiting for that, especially for changing the header description foreground colors in modernui


Yes! How soon? :rolleyes:


Originally posted by Joost Verburg
Support for changing text foreground colors will be added soon (for the whole NSIS UI, not only IO).
Will this include MessageBoxes?

No. You can't change the color of messagebox texts (not supported by Windows).


:weird: :down: :weird:



(I know it's not your fault)


*cough* latest newstuff *cough*


mmmm....