- NSIS Discussion
- Change description font in component page
Archive: Change description font in component page
nsisuser
29th October 2006 12:59 UTC
Change description font in component page
I'm using UMUI for my installer and the default message in the description box is very hard to read (you know the one saying "Position your mouse over a component to see its description").
I tried to change the font using this code, but no luck -- it only changed the "onmouseOver" description text :
Function "ComponentShow"
FindWindow $0 "#32770" "" $HWNDPARENT
GetDlgItem $0 $0 1043
CreateFont $1 "Arial" 8 0
SendMessage $0 ${WM_SETFONT} $1 0
SetCtlColors $0 000000 TRANSPARENT
FunctionEnd
Anyone can help me with this ?
Animaether
29th October 2006 18:32 UTC
Looks like MUI is doing funky things. The only way to make this work cleanly that I've found is to specify a non-transparent background color;
FindWindow $0 "#32770" "" $HWNDPARENT
GetDlgItem $0 $0 1043
CreateFont $1 "Arial" 12 400
SendMessage $0 ${WM_SETFONT} $1 0
SetCtlColors $0 0x000000 0xd4d0c8
The problem is in the '0xd4d0c8'. That color is defined somewhere on the system as being the background color for dialogs. But I'll be darned if I can find where. There's...
HKCU\Control Panel\Colors
...where matching values on my machine are for:
- ButtonFace
- InactiveTitleText
- Menu
- Scrollbar
But none of those particularly strike me as being -the- color used by dialogs. 'll have to look further, or let somebody else butt in about how to get the dialog's color :)
Edit:
"ButtonFace" is the one of interest.
Now the next problem is this.. the registry stores the values as "intR intG intB". How on Eerth to get a hex -value- out of that. I can easily turn it into a hex string (splice the string into its three bits, convert each three bits from decimal to hexadecimal).
However...
StrCpy $2 "0xff0000"
SetCtlColors <handle> $2
does not result in the same effect as:
SetCtlColors <handle> "0xff0000"
I'm rather stuck on that part. Anybody? %)
Animaether
30th October 2006 00:24 UTC
and I guess as much is noted in the manual:
text_color and bg_color don't accept variables.
Also tried trickery with /BRANDING , but the original problem occurs.
So I'm afraid that as far as my tests go, you'll either..
- have to live with the font 'as is'
- use a resource hacker to force a bigger font (see MUI docs)
- do use setctlcolors, but with a non-transparent background, which means
-- force a particular background color, which may not be the user's system color for the backgrounds
-- force your entire installer to be in a particular color, so that the above is rendered moot %)
Animaether
30th October 2006 00:41 UTC
Okay, here we go... just bypass MUI altogether.
Note that you -cannot- use:
!insertmacro MUI_FUNCTION_DESCRIPTION_BEGIN
!insertmacro MUI_DESCRIPTION_TEXT <section> <string>
!insertmacro MUI_FUNCTION_DESCRIPTION_END
As using those will throw a duplicate function error...
"MUI.nsh"
>!include "LogicLib.nsh"
>Name "Modern UI Test"
>OutFile "Basic.exe"
>!define MUI_PAGE_CUSTOMFUNCTION_SHOW ChangeFont
>!insertmacro MUI_PAGE_COMPONENTS
>!insertmacro MUI_PAGE_INSTFILES
>!insertmacro MUI_LANGUAGE "English"
>Function ChangeFont
FindWindow$0 "#32770" "" $HWNDPARENT
GetDlgItem$0 $0 1043
CreateFont$1 "Times New Roman" 12 400
SendMessage$0 ${WM_SETFONT} $1 0
FunctionEnd
Section"Dummy Section 1" SecDummy
SectionEnd
Section"Dummy Section 2" SecDummy2
SectionEnd
>Function .onMouseOverSection
FindWindow $R0"#32770" "" $HWNDPARENT
GetDlgItem $R0 $R0 1043; description item
${If} $0 == -1
EnableWindow $R0 0
SendMessage $R0${WM_SETTEXT} 0 "STR:Position your mouse over a component to see its description"
${Else}
EnableWindow $R0 1
${If} $0 == 0
SendMessage $R0${WM_SETTEXT} 0 "STR:first section description"
${ElseIf} $0 == 1
SendMessage $R0${WM_SETTEXT} 0 "STR:second section description"
${EndIf}
${EndIf}
>FunctionEnd
>
nsisuser
30th October 2006 11:59 UTC
Thanks for this code. At least, I know how to access the default text "Position your mouse..." --
But there is one more question : How can I get rid of the "engraved" look of the default text ?
Afrow UK
30th October 2006 12:03 UTC
EnableWindow $R0 0 gives it the engraved look, so just change it to 1 or try removing all EnableWindow instructions.
-Stu
Animaether
30th October 2006 12:30 UTC
MUI starts with the default text engraved (disabled), so you have to enable it first (in the area where you change the font). After that you can do away with the rest of the EnableWindow statements.
"MUI.nsh"
>!include "LogicLib.nsh"
>Name "Modern UI Test"
>OutFile "Basic.exe"
>!define MUI_PAGE_CUSTOMFUNCTION_SHOW ChangeFont
>!insertmacro MUI_PAGE_COMPONENTS
>!insertmacro MUI_PAGE_INSTFILES
>!insertmacro MUI_LANGUAGE "English"
>Function ChangeFont
FindWindow$0 "#32770" "" $HWNDPARENT
GetDlgItem$0 $0 1043
CreateFont$1 "Times New Roman" 12 400
SendMessage$0 ${WM_SETFONT} $1 0
EnableWindow$0 1
FunctionEnd
Section"Dummy Section 1" SecDummy
SectionEnd
Section"Dummy Section 2" SecDummy2
SectionEnd
>Function .onMouseOverSection
FindWindow $R0"#32770" "" $HWNDPARENT
GetDlgItem $R0 $R0 1043; description item
${Select} $0
${Case} -1
SendMessage $R0${WM_SETTEXT} 0 "STR:Position your mouse over a component to see its description"
${Case} 0
SendMessage $R0${WM_SETTEXT} 0 "STR:first section description"
${Case} 1
SendMessage $R0${WM_SETTEXT} 0 "STR:second section description"
${EndSelect}
>FunctionEnd
>
nsisuser
30th October 2006 12:39 UTC
Works like a charm. Thanks.
Why is it that the "disabled" look is so awful in UMUI and looks OK in all other templates. Is there a way to change how the "disabled font" is rendered ?
Animaether
30th October 2006 12:55 UTC
I'm not sure what it looks like in UltraModern UI - it doesn't look too great in MUI in the location it is, though. It's just not a very good place to have a piece of disabled text :)
I don't think there is a way to change what a disabled control looks like from within NSIS. It should just render with the default disabled control 'look' (e.g. like a browser 'Back' label when you're on a fresh new page). But you can always give it any color you'd like using the earlier code.
nsisuser
30th October 2006 15:44 UTC
Thanks a lot for all the insights, Animaether. I was finally able to get nsis to do exactly what I wanted.
For others who might be interested, here's the code I came up with in order to make the default description show in one color (light blue) and the section descriptions in another color (white)
"UMUI.nsh"
>!include "LogicLib.nsh"
>Name "Modern UI Test"
>OutFile "Font text.exe"
>!define MUI_PAGE_CUSTOMFUNCTION_SHOW ChangeFont
>!insertmacro MUI_PAGE_COMPONENTS
>!insertmacro MUI_PAGE_INSTFILES
>!insertmacro MUI_LANGUAGE "English"
>Function ChangeFont
FindWindow$0 "#32770" "" $HWNDPARENT
GetDlgItem$0 $0 1043
CreateFont$1 "Arial" 8 400
SendMessage$0 ${WM_SETFONT} $1 0
EnableWindow $R0 1
FunctionEnd
Section"Dummy Section 1" SecDummy
SectionEnd
Section"Dummy Section 2" SecDummy2
SectionEnd
>Function .onMouseOverSection
FindWindow $R0"#32770" "" $HWNDPARENT
GetDlgItem $R0 $R0 1043; description item
${If} $0 == -1
CreateFont$1 "Arial" 9 700 ; create the font for the default description
SetCtlColors $R0 0xBDBED5 0x3d66ab; set colors to : font light blue (0xBDBED5) - bg blue (0x3d66ab)
SendMessage $R0 ${WM_SETFONT} $1 0
SendMessage $R0${WM_SETTEXT} 0 "STR:Position your mouse over a component to see its description"
${Else}
CreateFont $1 "Arial" 9 400 ; create the font for mouse over descriptions
SetCtlColors $R0 0xFFFFFF 0x3d66ab; set colors to : font white (0xffffff) - bg blue (0x3d66ab)
SendMessage $R0 ${WM_SETFONT} $1 0
; show description for each section
${If} $0 == 0
SendMessage $R0${WM_SETTEXT} 0 "STR:first section description"
${ElseIf} $0 == 1
SendMessage $R0${WM_SETTEXT} 0 "STR:second section description"
${EndIf}
${EndIf}
>FunctionEnd
>
Have a nice day !
Chris