Archive: newbie: MUI_CUSTOMFUNCTION_ABORT


newbie: MUI_CUSTOMFUNCTION_ABORT
This question is comparable to one that I asked a few weeks ago, but is more concise. I hope that someone can help me, and if so, thank you.

I'm using MUI. I've defined a custom page that reads from an INI file, to determine whether tar is located in the chosen directory.

My problem is that when the user clicks "cancel" on the custom page, the installation won't stop unless the condition is met that tar is located in the chosen directory. As I've done it below - defining a MUI_CUSTOMFUNCTION_ABORT funtion that just issues a "quit" command - the installation won't abort until the user clicks "next".

Here're (what I think are) the relevant code snippets:


!define MUI_CUSTOMFUNCTION_ABORT "FunctionName"
...
Page custom FindingTarPage
Page components
Page instfiles
...
Function FindingTarPage
!insertmacro MUI_HEADER_TEXT "$(FINDTAR_TITLE)" "$(FINDTAR_SUBTITLE)"
!insertmacro MUI_INSTALLOPTIONS_DISPLAY "FindTar"
!insertmacro MUI_INSTALLOPTIONS_READ $locOfTar "FindTar" "Field 2" "State"
IfFileExists $locOfTar\tar.exe +3 0
MessageBox MB_OKCANCEL "tar.exe is not present in that directory. Try again, or press cancel to exit the installer." IDOK -4 IDCANCEL 0
Quit
FunctionEnd

Function FunctionName
Quit
FunctionEnd

To clarify: What I'd like to know is whether there's some way for me to modify, directly, what events occur when the user hits "next" or "cancel" on a custom page.


you could upon fail change the next button text to exit so when they hit next which is now labeled exit the installer quits


The MUI_CUSTOMFUNCTION_ABORT execute after click Cancel button and YES to exit...


there many way to cancel during installation...but i found one way to make it work!

I modify MUI

!macro MUI_ABORTWARNING

!ifdef MUI_FINISHPAGE_ABORTWARNINGCHECK
StrCmp $MUI_NOABORTWARNING "1" mui.quit
!endif

!ifdef MUI_ABORT_DURING_INSTALL
StrCmp $MUI_ABORT_DURING_INSTALL "" mui.before_installing
StrCpy $MUI_ABORT_DURING_INSTALL 1
Abort
mui.before_installing:
MessageBox MB_YESNO|MB_ICONEXCLAMATION "${MUI_ABORTWARNING_TEXT}" IDYES mui.quit

Abort

!else
MessageBox MB_YESNO|MB_ICONEXCLAMATION "${MUI_ABORTWARNING_TEXT}" IDYES mui.quit

Abort
!endif

mui.quit:
!macroend

this macro so simple

!macro _RunCmd _Cmd
!verbose push
!verbose 3

${If} $MUI_ABORT_DURING_INSTALL == 1
${If} ${Cmd} `MessageBox MB_YESNO|MB_ICONEXCLAMATION "${MUI_ABORTWARNING_TEXT}" IDYES`
Call DumpLog
Abort
${EndIf}
StrCpy $MUI_ABORT_DURING_INSTALL "0"
${EndIf}

${_Cmd}

!verbose pop
!macroend
!define RunCmd `!insertmacro _RunCmd`

here an example

Section ""
StrCpy $MUI_ABORT_DURING_INSTALL "0"
${RunCmd} 'File "COM Explorer\comexp.exe"'
SectionEnd


why nobody say nothing to func ???

anyway i just found a very cool thing combine with my old function ... my installer have 3 install pages run First page install files, 2nd page create shortcuts and 3rd page create reg keys. it's so cool

i replace my macro ${RunCmd} with 3 macros

!macro _File _Argu
!verbose push
!verbose 3

${If} $MUI_ABORT_DURING_INSTALL == 1
${If} ${Cmd} `MessageBox MB_YESNO|MB_ICONEXCLAMATION "${MUI_ABORTWARNING_TEXT}" IDYES`
;Call DumpLog
Abort
${EndIf}
StrCpy $MUI_ABORT_DURING_INSTALL "0"
${EndIf}

${If} $MUI_INSTALLPAGE_RUN == 1
${_Argu}
${EndIf}

!verbose pop
!macroend
!define File `!insertmacro _File`

!macro _Icon _Argu
!verbose push
!verbose 3

${If} $MUI_ABORT_DURING_INSTALL == 1
${If} ${Cmd} `MessageBox MB_YESNO|MB_ICONEXCLAMATION "${MUI_ABORTWARNING_TEXT}" IDYES`
;Call DumpLog
Abort
${EndIf}
StrCpy $MUI_ABORT_DURING_INSTALL "0"
${EndIf}

${If} $MUI_INSTALLPAGE_RUN == 2
${_Argu}
${EndIf}

!verbose pop
!macroend
!define Icon `!insertmacro _Icon`

!macro _Reg _Argu
!verbose push
!verbose 3

${If} $MUI_ABORT_DURING_INSTALL == 1
${If} ${Cmd} `MessageBox MB_YESNO|MB_ICONEXCLAMATION "${MUI_ABORTWARNING_TEXT}" IDYES`
;Call DumpLog
Abort
${EndIf}
StrCpy $MUI_ABORT_DURING_INSTALL "0"
${EndIf}

${If} $MUI_INSTALLPAGE_RUN == 3
${_Argu}
${EndIf}

!verbose pop
!macroend
!define Reg `!insertmacro _Reg`

declare 2 var MUI_INSTALLPAGE_RUN, MUI_ABORT_DURING_INSTALL of course.
Here sample how to use my macros:
Var MUI_ABORT_DURING_INSTALL
Var MUI_INSTALLPAGE_RUN

!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_INSTFILES
!insertmacro MUI_PAGE_INSTFILES


Section ""
GetDlgItem $R1 $HWNDPARENT 2 ;Enable Cancel Button
EnableWindow $R1 1
StrCpy $MUI_ABORT_DURING_INSTALL 0
IntOp $MUI_INSTALLPAGE_RUN $MUI_INSTALLPAGE_RUN + 1

${File} 'File "History.txt"'
${File} 'File "autorun.ldr"'
${File} 'File "APMUtils.dll"'
${File} 'File "APMHelp.chm"'

${Icon} '!insertmacro MUI_STARTMENU_WRITE_BEGIN Application'
${Icon} 'CreateDirectory "$SMPROGRAMS\$ICONS_GROUP"'
${Icon} 'CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Virtual Drive Manager.lnk" "$INSTDIR\VrDrvMan.exe"'
${Icon} 'CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\AutoPlay Menu Builder.lnk" "$INSTDIR\APMBuilder.exe"'
${Icon} 'CreateShortCut "$SMPROGRAMS\$ICONS_GROUP\Uninstall.lnk" "$INSTDIR\Uninstall.exe"'
${Icon} '!insertmacro MUI_STARTMENU_WRITE_END'

${Reg} 'WriteRegStr HKLM "SOFTWARE\Classes\.apm" "" "apmbldfile"'
${Reg} 'WriteRegStr HKLM "SOFTWARE\Classes\apmbldfile" "" "AutoPlay Menu Data"'
${Reg} 'WriteRegStr HKLM "SOFTWARE\Classes\apmbldfile\DefaultIcon" "" "$INSTDIR\APMBuilder.exe,1"'
${Reg} `WriteRegStr HKLM "SOFTWARE\Classes\apmbldfile\Shell\Open\command" "" '"$INSTDIR\APMBuilder.exe" "%1"'`
SectionEnd