Demonstrating Page's Custom Functions Pre Show Leave: Difference between revisions
From NSIS Wiki
Jump to navigationJump to search
No edit summary |
No edit summary |
||
Line 163: | Line 163: | ||
</highlight-nsis> | </highlight-nsis> | ||
== License == | |||
This demonstration is provided 'as-is', without any express or implied | |||
warranty. In no event will the author be held liable for any damages | |||
arising from the use of this code. | |||
Permission is granted to anyone to use this demonstration for any purpose, | |||
including commercial applications, and to alter it and redistribute | |||
it freely. | |||
[[Category:Tutorials]] | [[Category:Tutorials]] | ||
[[Category:Code Examples]] | [[Category:Code Examples]] |
Revision as of 05:59, 17 January 2007
Author: Red Wine (talk, contrib) |
Description
The following script example demonstrates several but not all possible usages of the custom functions PRE SHOW LEAVE that could be used to manage installer pages.
The Code
!define APP_NAME 'Test' name ${APP_NAME} outfile '${APP_NAME}.exe' showinstdetails show InstallDir '$PROGRAMFILES\${APP_NAME}' !include 'mui.nsh' !define MUI_PAGE_CUSTOMFUNCTION_PRE wel_pre !define MUI_PAGE_CUSTOMFUNCTION_SHOW wel_show !insertmacro MUI_PAGE_WELCOME !define MUI_PAGE_CUSTOMFUNCTION_SHOW lic_show !define MUI_PAGE_CUSTOMFUNCTION_LEAVE lic_leave !insertmacro MUI_PAGE_LICENSE '${NSISDIR}\License.txt' !define MUI_PAGE_CUSTOMFUNCTION_PRE dir_pre !define MUI_PAGE_CUSTOMFUNCTION_LEAVE dir_leave !insertmacro MUI_PAGE_DIRECTORY !define MUI_PAGE_CUSTOMFUNCTION_PRE comp_pre !insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_PAGE_INSTFILES !insertmacro MUI_LANGUAGE "English" Function wel_pre strcmp '$0' '1' noabort messagebox mb_yesno|mb_defbutton2|mb_iconquestion "Skip Welcome page?" idno noabort strcpy $0 2 abort noabort: strcpy $0 1 Functionend Function wel_show FindWindow $1 "#32770" "" $HWNDPARENT SetCtlColors $1 '' '0x000000' GetDlgItem $2 $1 1201 SetCtlColors $2 '0x00FF00' '0x000000' GetDlgItem $2 $1 1202 SetCtlColors $2 '0xFFFF00' '0x000000' CreateFont $1 "$(^Font)" "10" "" SendMessage $2 ${WM_SETFONT} $1 0 FunctionEnd Function lic_show StrCmp $R1 '0' btncheck FindWindow $1 "#32770" "" $HWNDPARENT GetDlgItem $1 $1 1000 CreateFont $2 "Comic Sans MS" "10" "700" SendMessage $1 ${WM_SETFONT} $2 0 btncheck: strcmp '$0' '2' 0 end GetDlgItem $1 $HWNDPARENT 3 EnableWindow $1 0 end: Functionend Function lic_leave intcmp '$R1' '1' next 0 next ShowWindow $HWNDPARENT "${SW_HIDE}" messagebox mb_ok|mb_iconexclamation 'You have pressed button I Agree, did you? \ Well, you have to press it one more time!' FindWindow $1 "#32770" "" $HWNDPARENT GetDlgItem $1 $1 1000 CreateFont $2 "$(^Font)" "8" "700" SendMessage $1 ${WM_SETFONT} $2 0 IntOp $R1 $R1 + 1 ShowWindow $HWNDPARENT "${SW_RESTORE}" abort next: strcmp $R1 '2' end messagebox mb_ok|mb_iconinformation 'Alright! Now you may step ahead!' end: call read_red Functionend Function read_red strcmp $R1 '2' end ShowWindow $HWNDPARENT "${SW_HIDE}" IntOp $R1 $R1 + 1 messagebox mb_ok|mb_iconstop "Oops you haven't read the whole sheet. \ You have to read it prior to agree!" GetDlgItem $1 $HWNDPARENT 1037 CreateFont $2 "$(^Font)" "10" "700" SendMessage $1 ${WM_SETFONT} $2 0 SetCtlColors $1 '0xFF0000' '0xFFFFFF' GetDlgItem $1 $HWNDPARENT 1038 CreateFont $2 "Tahoma" "9" "" SendMessage $1 ${WM_SETFONT} $2 0 SetCtlColors $1 '0xFF0000' '0xFFFFFF' ShowWindow $HWNDPARENT "${SW_RESTORE}" SendMessage $HWNDPARENT "0x408" "0" "0" Abort end: FunctionEnd Function dir_pre GetDlgItem $1 $HWNDPARENT 1037 CreateFont $2 "$(^Font)" "8" "700" SendMessage $1 ${WM_SETFONT} $2 0 SetCtlColors $1 '0x000000' '0xFFFFFF' GetDlgItem $1 $HWNDPARENT 1038 CreateFont $2 "$(^Font)" "8" "" SendMessage $1 ${WM_SETFONT} $2 0 SetCtlColors $1 '0x000000' '0xFFFFFF' Functionend Function dir_leave ShowWindow $HWNDPARENT "${SW_HIDE}" messagebox mb_yesno|mb_iconquestion "Skip components?" idno end push 'skip components' end: Functionend Function comp_pre pop $R0 StrCmp '$R0' 'skip components' 0 end messagebox mb_ok|mb_iconinformation 'you choose skip components!' ShowWindow $HWNDPARENT "${SW_RESTORE}" abort end: ShowWindow $HWNDPARENT "${SW_RESTORE}" Functionend Function .onInit StrCpy $0 0 StrCpy $R1 0 FunctionEnd Section 'boo' sleep 5000 Sectionend
License
This demonstration is provided 'as-is', without any express or implied warranty. In no event will the author be held liable for any damages arising from the use of this code.
Permission is granted to anyone to use this demonstration for any purpose, including commercial applications, and to alter it and redistribute it freely.