Archive: How to skip MUI_PAGE_DIRECTORY dialog?


How to skip MUI_PAGE_DIRECTORY dialog?
In case of upgrade from older to newer version
I would like to give a user option to "quick" upgrade into the same folder with no directory dialog showing.

How to prevent of appearing "Directory dialog" if, for example, $r0 = "QUICK_INSTALL"?

In other case (first install) "Directory dialog" is need, of cause. So I can't globally exclude
!insertmacro MUI_PAGE_DIRECTORY
But I have no idea how to manage this dialog


; this is an example for page_startmenu, but the same
; applies for the directory page

; for if,else usage ...
!include logiclib.nsh

;
!define MUI_PAGE_CUSTOMFUNCTION_PRE StartmenuPage_Show
!insertmacro MUI_PAGE_STARTMENU Application $StartMenuGroup

Function StartmenuPage_Show

${If} $InstallType = 3
Abort
${EndIf}

FunctionEnd

see "Customize Modern UI Functions" in MUI help (chapter 2.5) for explanation of PRE, SHOW, LEAVE functions.

excerpt:

;These defines should be set before inserting a page macro.

MUI_PAGE_CUSTOMFUNCTION_PRE function
MUI_PAGE_CUSTOMFUNCTION_SHOW function
MUI_PAGE_CUSTOMFUNCTION_LEAVE function

As shown above you use "Abort" in PRE-function to prevent it from appearing. In a Leave function "abort" is used to return to a page - useful for buttons clicks. The usage is "context-sensitive". Those functions and callback function as well are very powerful tools. Good luck!

An appetizer - the code below shows the page with directory read from registry but the browse button and the directory textfield are disabled and the standard page text is modified with a user-defined text telling the user that in installation was already found and so on....


!define MUI_PAGE_CUSTOMFUNCTION_SHOW Directory_Show
!insertmacro MUI_PAGE_DIRECTORY

Function Directory_Show

;exactly the example from user manual - 4.9.14.6
FindWindow $R1 "#32770" "" $HWNDPARENT

ReadRegStr $yourVar ${InstallRegKey}
;dumpstate::debug
StrCmp $yourVar "" FullDirectoryPage PartialDirectoryPage

PartialDirectoryPage:
## Change Directory Text
GetDlgItem $R0 $R1 1006
SendMessage $R0 ${WM_SETTEXT} 0 "STR:YourText"
EnableWindow $R0 1
#disable dir text
GetDlgItem $R2 $R1 1019
SendMessage $R2 ${WM_SETTEXT} 0 "STR:$yourVar"
EnableWindow $R2 0
#disable "browse button"
GetDlgItem $R2 $R1 1001
EnableWindow $R2 0
Return

FullDirectoryPage:
FunctionEnd


saschagottfried!

Lotta thanx for your advices!
1. MUI_PAGE_CUSTOMFUNCTION_PRE is very good feature really!
2. Thank you for mention of "logiclib.nsh". Up today I didn't know about this good stuff.