![]() |
#1 |
Senior Member
Join Date: Aug 2007
Location: Frankfurt, Germany
Posts: 187
|
MUI_PAGE_DIRECTORY Read Only
Hi all,
i am trying to get the MUI_PAGE_DIRECTORY Page to display the path "greyed out/read only" when it finds the Path Variable for that setup already set in the Registry. I am using !define MUI_PAGE_CUSTOMFUNCTION_PRE "PRE_PAGE_DIRECTORY" to determine the path and according to what it finds out would like to make the directory page read only. Any ideas how i could do that? Thanks xBarns |
![]() |
![]() |
![]() |
#2 | |
Major Dude
Join Date: Oct 2006
Posts: 1,892
|
From the MUI2 readme:
Quote:
http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.14.4 |
|
![]() |
![]() |
![]() |
#3 |
Senior Member
Join Date: Aug 2007
Location: Frankfurt, Germany
Posts: 187
|
I did actually read that but did not recognize it to be the solution to my problem.
For those interested here is how it works. code: Last edited by xbarns; 24th September 2009 at 13:22. |
![]() |
![]() |
![]() |
#4 |
Junior Member
Join Date: Jan 2009
Posts: 35
|
I'm trying to do the same thing and have to say your timing was perfect. Thanks for the code. But, when I implemented it, the path was not grayed out.
What I did was create a .nsh file called DetectDir.nsh containing the code you provided (with appropriate tweaks) and replaced my .nsi's !insertmacro MUI_PAGE_DIRECTORY statement with !insert DetectDir.nsh The code executes as I would expect - to prove it, I put a MessageBox under the line ${IF} $DISABLEDIRECTORY == 1 so the EnableWindow statements are executed. Yet the directory field is still active. What am I missing? |
![]() |
![]() |
![]() |
#5 | |
Senior Member
Join Date: Aug 2007
Location: Frankfurt, Germany
Posts: 187
|
uh,
i have no idea if Quote:
|
|
![]() |
![]() |
![]() |
#6 |
Junior Member
Join Date: Jan 2009
Posts: 35
|
I'm not sure what you're asking. The only thing I did was create a .nsh file containing your code with one line modified:
ReadRegStr $0 HKLM "SOFTWARE\myCompany\myProduct" "aKeyWithPathInfo" I made this a .nsh file for now because my .nsi file is fairly large and this helped me isolate your code so I could study it more easily in action. Running this I learned that $0 got loaded with the value of Path. All the logic works. It's just that the directory entry isn't disabled by the EnableWindow statements. |
![]() |
![]() |
![]() |
#7 |
Senior Member
Join Date: Aug 2007
Location: Frankfurt, Germany
Posts: 187
|
I think you have to keep
!insertmacro MUI_PAGE_DIRECTORY because if not the page will never be shown, or do you have the "!insertmacro MUI_PAGE_DIRECTORY" in your .nsh file? You can "export" the code to an .nsh file (the 2 functions) but you need to keep this: !define MUI_PAGE_CUSTOMFUNCTION_PRE "PRE_PAGE_DIRECTORY" !define MUI_PAGE_CUSTOMFUNCTION_SHOW "SHOW_PAGE_DIRECTORY" !insertmacro MUI_PAGE_DIRECTORY Or am i not getting something here? |
![]() |
![]() |
![]() |
#8 |
Junior Member
Join Date: Jan 2009
Posts: 35
|
I hope this isn't a double post. My browser keeps messing up my text. Anyway, thanks for taking the time to help me with this.
MyFile.nsh file contains this: !define MUI_PAGE_CUSTOMFUNCTION_PRE "PRE_PAGE_DIRECTORY" !define MUI_PAGE_CUSTOMFUNCTION_SHOW "SHOW_PAGE_DIRECTORY" !insertmacro MUI_PAGE_DIRECTORY Function PRE_PAGE_DIRECTORY Var /GLOBAL DISABLEDIRECTORY ReadRegStr $0 HKLM "SOFTWARE\myCompany\myProduct" "PathToExe" ${IF} $0 != '' StrCpy $DISABLEDIRECTORY 1 ${ANDIF} $0 != $INSTDIR StrCpy $INSTDIR $0 ${ENDIF} FunctionEnd Function SHOW_PAGE_DIRECTORY ${IF} $DISABLEDIRECTORY == 1 EnableWindow $mui.DirectoryPage.Directory 0 EnableWindow $mui.DirectoryPage.BrowseButton 0 ${ENDIF} FunctionEnd I commented out !insertmacro MUI_PAGE_DIRECTORY in the .nsi file and added !include myFile.nsh. When I run the code even without calling the two above functions from a section they still get invoked, due to the PRE prefix I figure. In any event, the directory page shows up with the path still editable. |
![]() |
![]() |
![]() |
#9 |
Junior Member
Join Date: Jan 2009
Posts: 35
|
Here's some relevant info. Looking at the log generated from the above code, I see this:
Function: "SHOW_PAGE_DIRECTORY" !insertmacro: _If !insertmacro: end of _If warning: unknown variable/constant "mui.DirectoryPage.Directory" detected, ignoring (MyFile.nsh:23) EnableWindow: handle=$mui.DirectoryPage.Directory enable=0 warning: unknown variable/constant "mui.DirectoryPage.BrowseButton" detected, ignoring (MyFile.nsh:24) EnableWindow: handle=$mui.DirectoryPage.BrowseButton enable=0 !insertmacro: _EndIf !insertmacro: end of _EndIf FunctionEnd For some reason the compiler doesn't see the Directory or BrowseButton. Directory.nsh has this: !macro MUI_FUNCTION_DIRECTORYPAGE PRE SHOW LEAVE --snip-- Function "${SHOW}" ;Get control handles FindWindow $mui.DirectoryPage "#32770" "" $HWNDPARENT GetDlgItem $mui.DirectoryPage.Text $mui.DirectoryPage 1006 GetDlgItem $mui.DirectoryPage.DirectoryBox $mui.DirectoryPage 1020 GetDlgItem $mui.DirectoryPage.Directory $mui.DirectoryPage 1019 GetDlgItem $mui.DirectoryPage.BrowseButton $mui.DirectoryPage 1001 --snip-- !insertmacro MUI_PAGE_FUNCTION_CUSTOM SHOW FunctionEnd --snip-- !macroend |
![]() |
![]() |
![]() |
#10 |
Major Dude
Join Date: Oct 2006
Posts: 1,892
|
You should not remove the page defines from your .nsi file. Remove them from the nsh and put them back in your real script, together with the other page commands/defines.
|
![]() |
![]() |
![]() |
#11 |
Junior Member
Join Date: Jan 2009
Posts: 35
|
Why would that make a difference? Aren't .nsh files simply in-lined? Anyway, I went ahead and copied all of the .nsh code into the .nsi. I get the same result. The telling symptom is the complier warnings:
unknown variable/constant "mui.DirectoryPage.Directory" detected, ignoring (myFile.nsi:162) unknown variable/constant "mui.DirectoryPage.BrowseButton" detected, ignoring (myFile.nsi:163) Any idea why they are undefined? |
![]() |
![]() |
![]() |
#12 | |
Major Dude
Join Date: Oct 2006
Posts: 1,892
|
Quote:
Anyway, are you sure you're including mui2.nsh, and not mui.nsh? |
|
![]() |
![]() |
![]() |
#13 |
Junior Member
Join Date: Jan 2009
Posts: 35
|
Here is a snippet of my code:
!include MUI2.nsh !insertmacro MUI_DEFAULT MUI_WELCOMEFINISHPAGE_BITMAP "${NSISDIR}\Contrib\Graphics\Wizard\main_left.bmp" !define MUI_ABORTWARNING !define MUI_ICON "${NSISDIR}\Contrib\Graphics\Icons\myIcon.ico" !define MUI_UNICON "${NSISDIR}\Contrib\Graphics\Icons\myUninstall.ico" !define MUI_WELCOMEPAGE_TITLE_3LINES !insertmacro MUI_PAGE_WELCOME !define MUI_LICENSEPAGE_CHECKBOX !insertmacro MUI_PAGE_LICENSE "my_eula.rtf" ; This is the macro I replace with the above code either directly or with the !include myFile.nsh. ;!insertmacro MUI_PAGE_DIRECTORY In one experiment, I tried including MUI.nsh In another I included neither MUI.nsh nor MUI2.nsh. In all three cases I got the same result, which is very surprising. |
![]() |
![]() |
![]() |
#14 |
Junior Member
Join Date: Jan 2009
Posts: 35
|
Okay, I found it. I had a myCode.nsi fiel and a myCode.nsh file. My build script was using the wrong file which indeed was calling !include MUI.nsh, not MUI2.nsh. When I call the right script it works as desired.
Thanks for your help and patience. |
![]() |
![]() |
![]() |
#15 |
Junior Member
Join Date: Sep 2020
Posts: 16
|
Thank you very much. I've been looking for this for days
|
![]() |
![]() |
![]() |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|