Skip to content
⌘ NSIS Forum Archive

Yet another onmouseover descriptions problem :)

10 posts

Kyoto#

Yet another onmouseover descriptions problem :)

Hey all

I'm working on an installer using NSIS and MUI



Problem N°1:

My problem is I can't seem to get to change the color of the descriptions text in the components page

I've tried searching the forums and searching again: all I've foud doesn't seem to work mith me, even thought it solved the problem for them


here are the parts of code in regard of this I use: (the complete script is quite huge so it's best if I only post the parts concerning this problem)

  !include "MUI.nsh"
!include "LogicLib.nsh"

;--------------------------------
;General

Name "blabla"
OutFile "blabla_Setup.exe"
InstallDir $PROGRAMFILES\blabla
InstallDirRegKey HKLM "Software\blabla power v185479.6.5.8" "Install_Dir"

;--------------------------------
;Interface Configuration

!define MUI_HEADERIMAGE
!define MUI_HEADERIMAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Header\myreallynice.bmp" ; optional
!define MUI_ABORTWARNING
!define MUI_PAGE_CUSTOMFUNCTION_SHOW ChangeFont

;--------------------------------
;Language Selection Dialog Settings

;Remember the installer language
!define MUI_LANGDLL_REGISTRY_ROOT "HKCU"
!define MUI_LANGDLL_REGISTRY_KEY "Software\whocares"
!define MUI_LANGDLL_REGISTRY_VALUENAME "Installer Language"

;--------------------------------
;Pages

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE $(MUILicense)
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MUI_PAGE_DIRECTORY
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_UNPAGE_CONFIRM
!insertmacro MUI_UNPAGE_INSTFILES
!insertmacro MUI_PAGE_FINISH

Function ChangeFont
FindWindow $0 "#32770" "" $HWNDPARENT
GetDlgItem $0 $0 1043
CreateFont $1 "Arial" 8 400
SendMessage $0 ${WM_SETFONT} $1 0
EnableWindow $0 1
FunctionEnd

and, right after the installation sections:

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 0x5f5f61 0xffffff; set colors
SendMessage $R0 ${WM_SETFONT} $1 0
SendMessage $R0 ${WM_SETTEXT} 0 "STR😁ON'T PLACE YOUR CURSOR HERE! (or your comp will crash so badly it will drill a hole in the soil)"
${Else}
CreateFont $1 "Arial" 9 400 ; create the font for mouse over descriptions
SetCtlColors $R0 0x5f5f61 0xffffff; set colors
SendMessage $R0 ${WM_SETFONT} $1 0
; show description for each section
${If} $0 == 0
SendMessage $R0 ${WM_SETTEXT} 0 "STR:This is a worm"
${ElseIf} $0 == 1
SendMessage $R0 ${WM_SETTEXT} 0 "STR:This is a cool virus"
${ElseIf} $0 == 2
SendMessage $R0 ${WM_SETTEXT} 0 "STR:This sux"
${ElseIf} $0 == 3
SendMessage $R0 ${WM_SETTEXT} 0 "STR:This... huh: no clue!"
${ElseIf} $0 == 4
SendMessage $R0 ${WM_SETTEXT} 0 "STR:This will give me your GF's credit card number"
${EndIf}
${EndIf}
FunctionEnd



I've tried changing the values for "SetCtlColors $R0 0x5f5f61 0xffffff", "EnableWindow $0 1" and trying parts of code from these forums so many times I think I might not actually survive...

the result is always the same: I can choose the background color but nothing seems to affect the font color


and that's really no luck at all, because what I'd like is exactly the contrary:
I'd like the background to remain system's button face color (not only mine please: the setting on the end user comp would be quite more classy) and the font color to be a plain simple black (engraving is ok, as long as it's "enabled", meaning with damn black somewhere in it ^^ )




Problem N°2:

of course, I have several sections:
one is required
four others are optionnal (but at least one has to be selected)

questions:
-is there a way to have these four sections unchecked by default?
-is there a way to make the installer refuse to continue if 2 or more of these 4 options are checked?
-is there a way to make the installer refuse to continue if none of these 4 options is checked?



I do understand I may ask a lot, but I'm really stuck and I've been for quite a while now, so any help would be rather appreciated 🙂

Thanks for reading anyway
bholliger#
Hi Kyoto!

let's begin with the second part:

> -is there a way to have these four sections unchecked by
> default?

Yes of course. Use
Section /o MySection MYSEC000
/o is for optional.

> -is there a way to make the installer refuse to continue
> if 2 or more of these 4 options are checked?
> -is there a way to make the installer refuse to continue
> if none of these 4 options is checked?

It is possible.

There are other possibilites as well. But I think that might be a good one.

!include logiclib.nsh
:
:
Function Validate
StrCpy $R1 0

${If} ${SectionIsSelected} ${Sec000}
IntOp $R1 $R1 + 1
${EndIf}
${If} ${SectionIsSelected} ${Sec00n}
IntOp $R1 $R1 + 1
${EndIf}
:
:
${If} $R1 <> 1
MessageBox MB_OK "Please make sure that you only select 1 of..."
Abort
${EndIf}
:
:
; Other validate code...
:
FunctionEnd

Cheers

Bruno
bholliger#
Hi Kyoto!

You have to move your definition of the custom function right before the page definition. Otherwise the function is executed by the welcome dialog, which has no effect.

!insertmacro MUI_PAGE_WELCOME
!insertmacro MUI_PAGE_LICENSE $(MUILicense)
!define MUI_PAGE_CUSTOMFUNCTION_SHOW ChangeFont
!insertmacro MUI_PAGE_COMPONENTS

Cheers

Bruno
Kyoto#edited
Thank you, bholliger (aka Bruno ^^), for helping me out! 🙂


all this was usefull:
-no more font color problems! (dang! am so happy to see them gone!)
-and it looks like I'm definately a few steps forward, thanks to you!
(I really did spend quite a few hours on this, and another "quite a few" searching these forums and all google has ever read about the word nsis 😁 )



I'm close, but there's still a few issues:

-> the compiler does not accept "Function Validate" you told me about, because it's "not referenced" (so he says)

I don't know what it means... I guess I have to declare something somewhere (or I've put some line after and not before some other line), but I obviously won't get it without your help 😁


-> I want the installer to launch little tools on completion:
1 a .bat file wich create a windows task for my exe
2 a .chm that explains why the hell I'm wasting my youth on all this to the user
3 a .hta witch basically gives easy access to some files that the user has to manually edit (oh well, after all, let's make him discover how cute notepad can be 😁 )

to do this, here's what I've put in my script: (come on: don't laugh! ^^ )
Function .onInstSuccess
Exec "$INSTDIR\Task.bat"
Exec "$INSTDIR\aide.chm"
Exec "$INSTDIR\Configuration.hta"
FunctionEnd
for some reason, only the 1rst file is launched...

I've tried making 3 separate "Function .onInstSuccess" but I soon realized that's not the way it should be ^^

maybe a timout problem? or the syntax just isn't good, I don't know


Any ideas?
Red Wine#
-> the compiler does not accept "Function Validate" you told me about, because it's "not referenced" (so he says)
!define MUI_PAGE_CUSTOMFUNCTION_LEAVE validation
!insertmacro MUI_PAGE_COMPONENTS
-> I want the installer to launch little tools on completion:
Function .onInstSuccess
Exec "$INSTDIR\Task.bat"
ExecShell open "$INSTDIR\aide.chm"
ExecShell open "$INSTDIR\Configuration.hta"
FunctionEnd
Kyoto#edited
Thanks Red Wine

I'm pretty sure the execShell open stuff will work perfectly but I didn't get that far:

"Error: resolving install function "validation" in function "mui.ComponentsLeave_36.5.12"
Note: uninstall functions must begin with "un.", and install functions must not"

I can't tell you more: I've no idea what's going on


edit:
since it might be usefull to see the whole script, I've uploaded it here:
MY.NSI
bholliger#
Hi Kyoto!

You're welcome!

MUI_PAGE_CUSTOMFUNCTION lets you set a function that is executed when the components page is left. The name of the function has to correspond with the name you define.

So you have to write


!define MUI_PAGE_CUSTOMFUNCTION_LEAVE validation
!insertmacro MUI_PAGE_COMPONENTS
:
:

Function validation
:
:
FunctionEnd
You'll find more information in the Modern UI Readme.

Cheers

Bruno
Red Wine#
Your script is perfect, you had just to change the validation function name with the real name of your function.
Validation >> Validate
Kyoto#
Great: I finally understand what was going wrong!

Thanks a lot guys



oh yes: by the way, Nsis "it really kicks a lama's ass!" 🙂
Red Wine#
Originally posted by Kyoto
oh yes: by the way, Nsis "it really kicks a lama's ass!
You got it:-)