testnotify.nsi 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. ; InstallOptions script demonstrating custom buttons
  2. ;----------------------------------------------------
  3. !include WinMessages.nsh
  4. ; The name of the installer
  5. Name "InstallOptions Test"
  6. ; The file to write
  7. OutFile "TestNotify.exe"
  8. ; Show install details
  9. ShowInstDetails show
  10. ; Called before anything else as installer initialises
  11. Function .onInit
  12. ; Extract InstallOptions files
  13. ; $PLUGINSDIR will automatically be removed when the installer closes
  14. InitPluginsDir
  15. File /oname=$PLUGINSDIR\test.ini "testnotify.ini"
  16. FunctionEnd
  17. ; Our custom page
  18. Page custom ShowCustom LeaveCustom ": Testing InstallOptions"
  19. Function ShowCustom
  20. ; Initialise the dialog but don't show it yet
  21. MessageBox MB_ICONQUESTION|MB_YESNO|MB_DEFBUTTON2 "Test the right-to-left version?" IDNO +2
  22. WriteINIStr "$PLUGINSDIR\test.ini" "Settings" "RTL" "1"
  23. InstallOptions::initDialog "$PLUGINSDIR\test.ini"
  24. ; In this mode InstallOptions returns the window handle so we can use it
  25. Pop $0
  26. ; Now show the dialog and wait for it to finish
  27. InstallOptions::show
  28. ; Finally fetch the InstallOptions status value (we don't care what it is though)
  29. Pop $0
  30. FunctionEnd
  31. Function LeaveCustom
  32. ; At this point the user has either pressed Next or one of our custom buttons
  33. ; We find out which by reading from the INI file
  34. ReadINIStr $0 "$PLUGINSDIR\test.ini" "Settings" "State"
  35. StrCmp $0 0 validate ; Next button?
  36. StrCmp $0 2 supportx ; "Install support for X"?
  37. StrCmp $0 9 clearbtn ; "Clear" button?
  38. StrCmp $0 11 droplist ; "Show|Hide" drop-list?
  39. Abort ; Return to the page
  40. supportx:
  41. ; Make the FileRequest field depend on the first checkbox
  42. ReadINIStr $0 "$PLUGINSDIR\test.ini" "Field 2" "State"
  43. ReadINIStr $1 "$PLUGINSDIR\test.ini" "Field 5" "HWND"
  44. EnableWindow $1 $0
  45. ReadINIStr $1 "$PLUGINSDIR\test.ini" "Field 5" "HWND2"
  46. EnableWindow $1 $0
  47. ; Add the disabled flag too so when we return to this page it's disabled again
  48. StrCmp $0 0 0 +3
  49. WriteINIStr "$PLUGINSDIR\test.ini" "Field 5" "Flags" "GROUP|FILE_MUST_EXIST|FILE_EXPLORER|FILE_HIDEREADONLY|DISABLED"
  50. Goto +2
  51. WriteINIStr "$PLUGINSDIR\test.ini" "Field 5" "Flags" "GROUP|FILE_MUST_EXIST|FILE_EXPLORER|FILE_HIDEREADONLY"
  52. Abort ; Return to the page
  53. clearbtn:
  54. ; Clear all text fields
  55. ReadINIStr $1 "$PLUGINSDIR\test.ini" "Field 5" "HWND"
  56. SendMessage $1 ${WM_SETTEXT} 0 "STR:"
  57. ReadINIStr $1 "$PLUGINSDIR\test.ini" "Field 6" "HWND"
  58. SendMessage $1 ${WM_SETTEXT} 0 "STR:"
  59. ReadINIStr $1 "$PLUGINSDIR\test.ini" "Field 8" "HWND"
  60. SendMessage $1 ${WM_SETTEXT} 0 "STR:"
  61. Abort ; Return to the page
  62. droplist:
  63. ; Make the DirRequest field depend on the droplist
  64. ReadINIStr $0 "$PLUGINSDIR\test.ini" "Field 11" "State"
  65. StrCmp $0 "Show" +3
  66. StrCpy $0 0
  67. Goto +2
  68. StrCpy $0 1
  69. ReadINIStr $1 "$PLUGINSDIR\test.ini" "Field 6" "HWND"
  70. EnableWindow $1 $0
  71. ReadINIStr $1 "$PLUGINSDIR\test.ini" "Field 6" "HWND2"
  72. EnableWindow $1 $0
  73. ; Add the disabled flag too so when we return to this page it's disabled again
  74. StrCmp $0 0 0 +3
  75. WriteINIStr "$PLUGINSDIR\test.ini" "Field 6" "Flags" "DISABLED"
  76. Goto +2
  77. WriteINIStr "$PLUGINSDIR\test.ini" "Field 6" "Flags" ""
  78. Abort ; Return to the page
  79. validate:
  80. ; At this point we know the Next button was pressed, so perform any validation
  81. ReadINIStr $0 "$PLUGINSDIR\test.ini" "Field 2" "State"
  82. StrCmp $0 1 done
  83. ReadINIStr $0 "$PLUGINSDIR\test.ini" "Field 3" "State"
  84. StrCmp $0 1 done
  85. ReadINIStr $0 "$PLUGINSDIR\test.ini" "Field 4" "State"
  86. StrCmp $0 1 done
  87. MessageBox MB_ICONEXCLAMATION|MB_OK "You must select at least one install option!"
  88. Abort
  89. done:
  90. FunctionEnd
  91. ; Installation page
  92. Page instfiles
  93. Section
  94. ;Get Install Options dialog user input
  95. ReadINIStr $0 "$PLUGINSDIR\test.ini" "Field 2" "State"
  96. DetailPrint "Install X=$0"
  97. ReadINIStr $0 "$PLUGINSDIR\test.ini" "Field 3" "State"
  98. DetailPrint "Install Y=$0"
  99. ReadINIStr $0 "$PLUGINSDIR\test.ini" "Field 4" "State"
  100. DetailPrint "Install Z=$0"
  101. ReadINIStr $0 "$PLUGINSDIR\test.ini" "Field 5" "State"
  102. DetailPrint "File=$0"
  103. ReadINIStr $0 "$PLUGINSDIR\test.ini" "Field 6" "State"
  104. DetailPrint "Dir=$0"
  105. ReadINIStr $0 "$PLUGINSDIR\test.ini" "Field 8" "State"
  106. DetailPrint "Info=$0"
  107. SectionEnd