- NSIS Discussion
- MUI_HWND not recognised
Archive: MUI_HWND not recognised
JohaViss
14th September 2010 15:34 UTC
MUI_HWND not recognised
Hello,
I am trying to hide the 'RUN' checkbox on the finishpage on a condition.
Using the following function:
Function HideCheckbox
${If} $InstallationChoice == "deinstall"
GetDlgItem $R9 $MUI_HWND "1203"
ShowWindow $R9 ${SW_HIDE}
${EndIf}
>FunctionEnd
>
Defined like this:
define MUI_PAGE_CUSTOMFUNCTION_SHOW HideCheckbox
>
But, the compiler give me a warning:
unknown variable/constant "MUI_HWND" detected, ignoring (installatie_keuze.nsh:63)
And the function doesn't work.
The function is called and the condition is true, but $R9 is always 0
Am I missing something?
Afrow UK
14th September 2010 15:42 UTC
If you're using MUI2 there's no longer a MUI_HWND variable. Instead you want $mui.FinishPage (or for the check boxes; $mui.FinishPage.Run or $mui.FinishPage.ShowReadme).
Stu
JohaViss
14th September 2010 15:53 UTC
I am using MUI 1
!include "MUI.nsh"
Afrow UK
14th September 2010 16:16 UTC
Switch to MUI2?
Stu
JohaViss
15th September 2010 08:49 UTC
Same problem.
Johan
Afrow UK
15th September 2010 10:39 UTC
In which case you must be using the variables before they are defined in the script.
Stu
JohaViss
15th September 2010 10:56 UTC
I don't think so.
I include the NSIS .nsh files before I include my own .nsh files.
The function 'HideCheckbox' is in a seperate .nsh file that's included after the MUI.nsh
I don't have to define the $MUI_HWND variable in my script?
Johan
Afrow UK
15th September 2010 11:03 UTC
The MUI_HWND variable is defined when you !insertmacro MUI_PAGE_WELCOME or !insertmacro MUI_PAGE_FINISH. You cannot reference it before. And seriously, unless you are using InstallOptions in your installer, you should switch to MUI2. It uses nsDialogs for its custom pages which is a lot faster than InstallOptions (and has less overhead).
Stu
JohaViss
15th September 2010 12:34 UTC
Switched to MUI2.
Changed $MUI_HWND to $mui.FinishPage.Run
Getting warning:
unknown variable
/constant "mui.FinishPage.Run" detected, ignoring (installatie_functies.nsh:89)
Order of includes and pages:
....
!
define MUI_LANGDLL_REGISTRY_ROOT "${PRODUCT_UNINST_ROOT_KEY}"
!define MUI_LANGDLL_REGISTRY_VALUENAME "NSIS:Language"
!define MUI_FINISHPAGE_TITLE_3LINES
!insertmacro MUI_PAGE_WELCOME
>; License page
!define MUI_LICENSEPAGE_CHECKBOX
!insertmacro MUI_PAGE_LICENSE ${LICENCEFILE}
;--------------------------------------------------------------------------------------------------
; custom pages
Page custom InstallChoiceInit InstallChoiceValidate
Page custom InstallTypeInit InstalTypeValidate
>.... More pages
>; Finish page
!define MUI_FINISHPAGE_RUN
!define MUI_FINISHPAGE_RUN_TEXT "Start MyApp"
!define MUI_FINISHPAGE_RUN_FUNCTION RunApplication
!define MUI_FINISHPAGE_SHOWREADME
!define MUI_FINISHPAGE_SHOWREADME_TEXT "View Log"
!define MUI_FINISHPAGE_SHOWREADME_FUNCTION ShowLogFile
!define MUI_PAGE_CUSTOMFUNCTION_SHOW HideCheckbox
!insertmacro MUI_DEFAULT MUI_FINISHPAGE_TITLE "Completing installation."
!insertmacro MUI_DEFAULT MUI_FINISHPAGE_TEXT "The installation completed."
!insertmacro MUI_PAGE_FINISH
>
The functions 'RunApplication', 'ShowLogFile' and 'HideCheckbox' are placed in a seperate file (Install_Functions.nsh)
Johan
MSG
15th September 2010 14:18 UTC
Then you're probably including your Install_Functions.nsh before you're inserting the page macros.
JohaViss
15th September 2010 15:13 UTC
Had to split my 'Install_Functions.nsh' into 2 files.
Moved the split off part to a position after the Finish_Page definition.
Then it works.
I am not happy to have include files on more than 1 place in the code.:down:
It's getting to be a mess. (I have just under 200 include files, and the .NSI alone is over 15.000 lines)
B.T.W.
Are there rules where to place certain parts of code? The help isn't clear about that.
We want to have equal call grouped together:
First all constants
Second all variables
Next all includes (Split into NSIS internal, Project specific, Custom pages)
Next all page definitions
Finally _PRE, _SHOW and _LEAVE functions
Johan
Afrow UK
15th September 2010 15:54 UTC
There are no rules, (except for the order of MUI macro/defines for example) it's just a matter of getting it right so that it builds OK. However I would always place functions after page definitions (and sometimes after sections too). How about moving your page definitions to another include?
Stu