Old 14th September 2010, 15:34   #1
JohaViss
Junior Member
 
Join Date: Apr 2010
Posts: 29
MUI_HWND not recognised

Hello,

I am trying to hide the 'RUN' checkbox on the finishpage on a condition.

Using the following function:

PHP Code:
Function HideCheckbox
  
${If} $InstallationChoice == "deinstall"
      
GetDlgItem $R9 $MUI_HWND "1203"  
      
ShowWindow $R9 ${SW_HIDE}
  ${EndIf}
FunctionEnd 
Defined like this:
PHP Code:
!define MUI_PAGE_CUSTOMFUNCTION_SHOW                HideCheckbox 
But, the compiler give me a warning:
PHP Code:
unknown variable/constant "MUI_HWND" detectedignoring (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?
JohaViss is offline   Reply With Quote
Old 14th September 2010, 15:42   #2
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
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
Afrow UK is offline   Reply With Quote
Old 14th September 2010, 15:53   #3
JohaViss
Junior Member
 
Join Date: Apr 2010
Posts: 29
I am using MUI 1

PHP Code:
!include "MUI.nsh" 
JohaViss is offline   Reply With Quote
Old 14th September 2010, 16:16   #4
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Switch to MUI2?

Stu
Afrow UK is offline   Reply With Quote
Old 15th September 2010, 08:49   #5
JohaViss
Junior Member
 
Join Date: Apr 2010
Posts: 29
Same problem.

Johan
JohaViss is offline   Reply With Quote
Old 15th September 2010, 10:39   #6
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
In which case you must be using the variables before they are defined in the script.

Stu
Afrow UK is offline   Reply With Quote
Old 15th September 2010, 10:56   #7
JohaViss
Junior Member
 
Join Date: Apr 2010
Posts: 29
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
JohaViss is offline   Reply With Quote
Old 15th September 2010, 11:03   #8
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
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
Afrow UK is offline   Reply With Quote
Old 15th September 2010, 12:34   #9
JohaViss
Junior Member
 
Join Date: Apr 2010
Posts: 29
Switched to MUI2.

Changed $MUI_HWND to $mui.FinishPage.Run

Getting warning:
PHP Code:
unknown variable/constant "mui.FinishPage.Run" detectedignoring (installatie_functies.nsh:89

Order of includes and pages:
PHP Code:
....
!
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
JohaViss is offline   Reply With Quote
Old 15th September 2010, 14:18   #10
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
Then you're probably including your Install_Functions.nsh before you're inserting the page macros.
MSG is offline   Reply With Quote
Old 15th September 2010, 15:13   #11
JohaViss
Junior Member
 
Join Date: Apr 2010
Posts: 29
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.
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
JohaViss is offline   Reply With Quote
Old 15th September 2010, 15:54   #12
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
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
Afrow UK is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump