Notice/Message before a page..
How can i put a message up just before the directory page apears... cos i want to tell them something before it apears or when it apears...
21 posts
Originally posted by XxXGoDThe .onVerifyInstDir function will be called every time the user changes the directory on the directory page. It will be called even when the user changes only one single character of the directory. And it will be called when a new folder is highlighted in the "Browse..." dialog. Therefore this function is not suitable for displaying message boxes. Make a custom "pre_function" as described in chapter "4.5.4 Page" of the NSIS manual. Reading the manual can help a lot...
I added:
Function .onVerifyInstDir
MessageBox MB_OK "My message"
FunctionEnd
But it shows at end of component page and start of directory page...
; pages
page directory MyPreDirectoryFunction
[..]
Function MyPreDirectoryFunction
MessageBox MB_OK "Be warned, you'll have to choose a directory now!"
FunctionEnd
Make sure you put the XPUI_PAGE_CUSTOMFUNCTION_PRE define *directly* before the XPUI_PAGE_DIRECTORY macro! Do *not* put any other page macros in between! That's at least how it works with MUI, MUI2 and UMUI...; page macros
!define XPUI_PAGE_CUSTOMFUNCTION_PRE MyMessage
!insertmacro XPUI_PAGE_DIRECTORY
; custom functions
Function MyMessage
MessageBox MB_OK "My message"
FunctionEnd
!insertmacro: XPUI_PAGE_DIRECTORY
!insertmacro: XPUI_PAGECHECKS
Call must be used with function names starting with "un." in the uninstall section.
Usage: Call function_name | [:label_name]
Error in macro XPUI_PAGE_CUSTOMFUNCTION on macroline 3
Error in macro XPUI_PAGE_DIRECTORY on macroline 38
Error in script "C:\Documents and Settings\Ryan\Desktop\h1o.nsi" on line 110 -- aborting creation process
Using custom page/GUI functions[EDIT²]
XPUI_CUSTOMFUNCTION_GUIINIT myFunction - Define this to call custom function "myFunction" during the installer's GUI initialization.
XPUI_CUSTOMFUNCTION_GUIEND myFunction - Define this to call custom function "myFunction" during the installer's GUI de-initialization. Use this to unload any plugins you have and delete any temporary files that you dumped on to the user's hard drive.
XPUI_PAGE_CUSTOMFUNCTION_PRE myFunction - Call function "myFunction" during the early initialization of an installer page.
XPUI_PAGE_CUSTOMFUNCTION_SHOW myFunction - Call function "myFunction" right before an installer page shows.
XPUI_PAGE_CUSTOMFUNCTION_LEAVE myFunction - Call function "myFunction" while an installer page is unloading.
NOTE: After defining the XPUI_PAGE_CUSTOMFUNCTION symbols, insert the page of your choice, and that will be the page that calls your custom functions. You will need to define the CUSTOMFUNCTION symbols for every page that you want a custom function for.
Have to put the define in where the page's are and then move the rest of what you said below the pages
${Page} Welcome
; ${LicensePage} "E:\Documents and Settings\User\Desktop\lic.rtf"
${Page} Components
!define XPUI_PAGE_CUSTOMFUNCTION_PRE AccountDir
${Page} Directory
${Page} InstFiles
${Page} Finish
; open file
ClearErrors
FileOpen $0 "autoexec.cfg" a
IfErrors FileErrors
; seek to the end of the file
FileSeek $0 0 END
; append a few lines
FileWrite $0 "Rabbit$\r$\n"
FileWrite $0 "Umbrella$\r$\n"
FileWrite $0 "Joker$\r$\n"
; close file
FileClose $0
FileErrors:
Originally posted by LoRd_MuldeRBut theres 1 file what i dont want it to overwrite.
You can check for file existence with IfFileExists command 😉
Also, the above code should work, no matter if the file exists before or not...
Is that right?
IfFileExists $INSTDIR\autoexec.cfg autoexecfound
File "C:\Documents and Settings\Ryan\Desktop\autoexec.cfg"
autoexecfound:
ClearErrors
FileOpen $0 "$INSTDIR\autoexec.cfg" a
IfErrors FileErrors
FileSeek $0 0 END
FileWrite $0 "TestLine$\r$\n"
FileClose $0
FileErrors:
IfFileExists $INSTDIR\autoexec.cfg autoexecfound
File "C:\Documents and Settings\Ryan\Desktop\autoexec.cfg"
autoexecfound:
ClearErrors
FileOpen $0 "$INSTDIR\autoexec.cfg" a
IfErrors FileErrors
FileSeek $0 0 END
FileWrite $0 "$\r$\n" ; <-- THIS IS NEW
FileWrite $0 "TestLine$\r$\n"
FileClose $0
FileErrors:
IfFileExists $INSTDIR\autoexec.cfg autoexecfound
File "C:\Documents and Settings\Ryan\Desktop\autoexec.cfg"
autoexecfound:
ClearErrors
FileOpen $0 "$INSTDIR\autoexec.cfg" a
IfErrors FileErrors
FileSeek $0 1 END
FileReadByte $0 $1
StrCmp $1 10 CarriageReturnFound:
FileWrite $0 "$\r$\n"
CarriageReturnFound:
FileWrite $0 "TestLine$\r$\n"
FileClose $0
FileErrors: