welcome.nsi 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320
  1. !include MUI.nsh
  2. !include LogicLib.nsh
  3. !include WinMessages.nsh
  4. !include FileFunc.nsh
  5. Name "nsDialogs Welcome"
  6. OutFile "nsDialogs Welcome.exe"
  7. Page custom nsDialogsWelcome
  8. Page custom nsDialogsDirectory
  9. !insertmacro MUI_PAGE_INSTFILES
  10. !insertmacro MUI_LANGUAGE English
  11. !define WS_EX_CLIENTEDGE 0x00000200
  12. !define WS_CHILD 0x40000000
  13. !define WS_VISIBLE 0x10000000
  14. !define WS_DISABLED 0x08000000
  15. !define WS_CLIPSIBLINGS 0x04000000
  16. !define WS_MAXIMIZE 0x01000000
  17. !define WS_VSCROLL 0x00200000
  18. !define WS_HSCROLL 0x00100000
  19. !define WS_GROUP 0x00020000
  20. !define WS_TABSTOP 0x00010000
  21. !define ES_LEFT 0x00000000
  22. !define ES_CENTER 0x00000001
  23. !define ES_RIGHT 0x00000002
  24. !define ES_MULTILINE 0x00000004
  25. !define ES_UPPERCASE 0x00000008
  26. !define ES_LOWERCASE 0x00000010
  27. !define ES_PASSWORD 0x00000020
  28. !define ES_AUTOVSCROLL 0x00000040
  29. !define ES_AUTOHSCROLL 0x00000080
  30. !define ES_NOHIDESEL 0x00000100
  31. !define ES_OEMCONVERT 0x00000400
  32. !define ES_READONLY 0x00000800
  33. !define ES_WANTRETURN 0x00001000
  34. !define ES_NUMBER 0x00002000
  35. !define SS_LEFT 0x00000000
  36. !define SS_CENTER 0x00000001
  37. !define SS_RIGHT 0x00000002
  38. !define SS_ICON 0x00000003
  39. !define SS_BLACKRECT 0x00000004
  40. !define SS_GRAYRECT 0x00000005
  41. !define SS_WHITERECT 0x00000006
  42. !define SS_BLACKFRAME 0x00000007
  43. !define SS_GRAYFRAME 0x00000008
  44. !define SS_WHITEFRAME 0x00000009
  45. !define SS_USERITEM 0x0000000A
  46. !define SS_SIMPLE 0x0000000B
  47. !define SS_LEFTNOWORDWRAP 0x0000000C
  48. !define SS_OWNERDRAW 0x0000000D
  49. !define SS_BITMAP 0x0000000E
  50. !define SS_ENHMETAFILE 0x0000000F
  51. !define SS_ETCHEDHORZ 0x00000010
  52. !define SS_ETCHEDVERT 0x00000011
  53. !define SS_ETCHEDFRAME 0x00000012
  54. !define SS_TYPEMASK 0x0000001F
  55. !define SS_REALSIZECONTROL 0x00000040
  56. !define SS_NOPREFIX 0x00000080
  57. !define SS_NOTIFY 0x00000100
  58. !define SS_CENTERIMAGE 0x00000200
  59. !define SS_RIGHTJUST 0x00000400
  60. !define SS_REALSIZEIMAGE 0x00000800
  61. !define SS_SUNKEN 0x00001000
  62. !define SS_EDITCONTROL 0x00002000
  63. !define SS_ENDELLIPSIS 0x00004000
  64. !define SS_PATHELLIPSIS 0x00008000
  65. !define SS_WORDELLIPSIS 0x0000C000
  66. !define SS_ELLIPSISMASK 0x0000C000
  67. !define BS_PUSHBUTTON 0x00000000
  68. !define BS_DEFPUSHBUTTON 0x00000001
  69. !define BS_CHECKBOX 0x00000002
  70. !define BS_AUTOCHECKBOX 0x00000003
  71. !define BS_RADIOBUTTON 0x00000004
  72. !define BS_3STATE 0x00000005
  73. !define BS_AUTO3STATE 0x00000006
  74. !define BS_GROUPBOX 0x00000007
  75. !define BS_USERBUTTON 0x00000008
  76. !define BS_AUTORADIOBUTTON 0x00000009
  77. !define BS_PUSHBOX 0x0000000A
  78. !define BS_OWNERDRAW 0x0000000B
  79. !define BS_TYPEMASK 0x0000000F
  80. !define BS_LEFTTEXT 0x00000020
  81. !define BS_TEXT 0x00000000
  82. !define BS_ICON 0x00000040
  83. !define BS_BITMAP 0x00000080
  84. !define BS_LEFT 0x00000100
  85. !define BS_RIGHT 0x00000200
  86. !define BS_CENTER 0x00000300
  87. !define BS_TOP 0x00000400
  88. !define BS_BOTTOM 0x00000800
  89. !define BS_VCENTER 0x00000C00
  90. !define BS_PUSHLIKE 0x00001000
  91. !define BS_MULTILINE 0x00002000
  92. !define BS_NOTIFY 0x00004000
  93. !define BS_FLAT 0x00008000
  94. !define BS_RIGHTBUTTON ${BS_LEFTTEXT}
  95. !define LR_DEFAULTCOLOR 0x0000
  96. !define LR_MONOCHROME 0x0001
  97. !define LR_COLOR 0x0002
  98. !define LR_COPYRETURNORG 0x0004
  99. !define LR_COPYDELETEORG 0x0008
  100. !define LR_LOADFROMFILE 0x0010
  101. !define LR_LOADTRANSPARENT 0x0020
  102. !define LR_DEFAULTSIZE 0x0040
  103. !define LR_VGACOLOR 0x0080
  104. !define LR_LOADMAP3DCOLORS 0x1000
  105. !define LR_CREATEDIBSECTION 0x2000
  106. !define LR_COPYFROMRESOURCE 0x4000
  107. !define LR_SHARED 0x8000
  108. !define IMAGE_BITMAP 0
  109. !define IMAGE_ICON 1
  110. !define IMAGE_CURSOR 2
  111. !define IMAGE_ENHMETAFILE 3
  112. Var DIALOG
  113. Var HEADLINE
  114. Var TEXT
  115. Var IMAGECTL
  116. Var IMAGE
  117. Var DIRECTORY
  118. Var FREESPACE
  119. Var HEADLINE_FONT
  120. Function .onInit
  121. CreateFont $HEADLINE_FONT "$(^Font)" "14" "700"
  122. InitPluginsDir
  123. File /oname=$PLUGINSDIR\welcome.bmp "${NSISDIR}\Contrib\Graphics\Wizard\orange-nsis.bmp"
  124. FunctionEnd
  125. Function HideControls
  126. LockWindow on
  127. GetDlgItem $0 $HWNDPARENT 1028
  128. ShowWindow $0 ${SW_HIDE}
  129. GetDlgItem $0 $HWNDPARENT 1256
  130. ShowWindow $0 ${SW_HIDE}
  131. GetDlgItem $0 $HWNDPARENT 1035
  132. ShowWindow $0 ${SW_HIDE}
  133. GetDlgItem $0 $HWNDPARENT 1037
  134. ShowWindow $0 ${SW_HIDE}
  135. GetDlgItem $0 $HWNDPARENT 1038
  136. ShowWindow $0 ${SW_HIDE}
  137. GetDlgItem $0 $HWNDPARENT 1039
  138. ShowWindow $0 ${SW_HIDE}
  139. GetDlgItem $0 $HWNDPARENT 1045
  140. ShowWindow $0 ${SW_NORMAL}
  141. LockWindow off
  142. FunctionEnd
  143. Function ShowControls
  144. LockWindow on
  145. GetDlgItem $0 $HWNDPARENT 1028
  146. ShowWindow $0 ${SW_NORMAL}
  147. GetDlgItem $0 $HWNDPARENT 1256
  148. ShowWindow $0 ${SW_NORMAL}
  149. GetDlgItem $0 $HWNDPARENT 1035
  150. ShowWindow $0 ${SW_NORMAL}
  151. GetDlgItem $0 $HWNDPARENT 1037
  152. ShowWindow $0 ${SW_NORMAL}
  153. GetDlgItem $0 $HWNDPARENT 1038
  154. ShowWindow $0 ${SW_NORMAL}
  155. GetDlgItem $0 $HWNDPARENT 1039
  156. ShowWindow $0 ${SW_NORMAL}
  157. GetDlgItem $0 $HWNDPARENT 1045
  158. ShowWindow $0 ${SW_HIDE}
  159. LockWindow off
  160. FunctionEnd
  161. Function nsDialogsWelcome
  162. nsDialogs::Create 1044
  163. Pop $DIALOG
  164. nsDialogs::CreateControl STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${SS_BITMAP} 0 0 0 109u 193u ""
  165. Pop $IMAGECTL
  166. StrCpy $0 $PLUGINSDIR\welcome.bmp
  167. System::Call 'user32::LoadImage(i 0, t r0, i ${IMAGE_BITMAP}, i 0, i 0, i ${LR_LOADFROMFILE}) i.s'
  168. Pop $IMAGE
  169. SendMessage $IMAGECTL ${STM_SETIMAGE} ${IMAGE_BITMAP} $IMAGE
  170. nsDialogs::CreateControl STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 120u 10u -130u 20u "Welcome to nsDialogs!"
  171. Pop $HEADLINE
  172. SendMessage $HEADLINE ${WM_SETFONT} $HEADLINE_FONT 0
  173. nsDialogs::CreateControl STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 120u 32u -130u -32u "nsDialogs is the next generation of user interfaces in NSIS. It gives the developer full control over custom pages. Some of the features include control text containing variables, callbacks directly into script functions and creation of any type of control. Create boring old edit boxes or load some external library and create custom controls with no need of creating your own plug-in.$\r$\n$\r$\nUnlike InstallOptions, nsDialogs doesn't use INI files to communicate with the script. By interacting directly with the script, nsDialogs can perform much faster without the need of costly, old and inefficient INI operations. Direct interaction also allows direct calls to functions defined in the script and removes the need of conversion functions like Io2Nsis.$\r$\n$\r$\nHit the Next button to see how it all fits into a mock directory page."
  174. Pop $TEXT
  175. SetCtlColors $DIALOG "" 0xffffff
  176. SetCtlColors $HEADLINE "" 0xffffff
  177. SetCtlColors $TEXT "" 0xffffff
  178. Call HideControls
  179. nsDialogs::Show
  180. Call ShowControls
  181. System::Call gdi32::DeleteObject(i$IMAGE)
  182. FunctionEnd
  183. !define SHACF_FILESYSTEM 1
  184. Function nsDialogsDirectory
  185. !insertmacro MUI_HEADER_TEXT "Choose Install Location" "Choose the folder in which to install $(^NameDA)."
  186. GetDlgItem $0 $HWNDPARENT 1
  187. EnableWindow $0 0
  188. nsDialogs::Create 1018
  189. Pop $DIALOG
  190. nsDialogs::CreateControl STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${SS_CENTER} 0 0 0 100% 30 "Directory page"
  191. Pop $HEADLINE
  192. SendMessage $HEADLINE ${WM_SETFONT} $HEADLINE_FONT 0
  193. nsDialogs::CreateControl STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 0 30 100% 40 "Select the installation directory of NSIS to continue. $_CLICK"
  194. Pop $TEXT
  195. nsDialogs::CreateControl EDIT ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS}|${ES_AUTOHSCROLL}|${WS_TABSTOP} ${WS_EX_CLIENTEDGE} 0 75 100% 12u ""
  196. Pop $DIRECTORY
  197. SendMessage $HWNDPARENT ${WM_NEXTDLGCTL} $DIRECTORY 1
  198. GetFunctionAddress $0 DirChange
  199. nsDialogs::OnChange $DIRECTORY $0
  200. System::Call shlwapi::SHAutoComplete(i$DIRECTORY,i${SHACF_FILESYSTEM})
  201. nsDialogs::CreateControl STATIC ${WS_VISIBLE}|${WS_CHILD}|${WS_CLIPSIBLINGS} 0 0 -10u 100% 10u ""
  202. Pop $FREESPACE
  203. Call UpdateFreeSpace
  204. nsDialogs::Show
  205. FunctionEnd
  206. Function UpdateFreeSpace
  207. ${GetRoot} $INSTDIR $0
  208. StrCpy $1 " bytes"
  209. System::Call kernel32::GetDiskFreeSpaceEx(tr0,*l,*l,*l.r0)
  210. ${If} $0 > 1024
  211. ${OrIf} $0 < 0
  212. System::Int64Op $0 / 1024
  213. Pop $0
  214. StrCpy $1 "kb"
  215. ${If} $0 > 1024
  216. ${OrIf} $0 < 0
  217. System::Int64Op $0 / 1024
  218. Pop $0
  219. StrCpy $1 "mb"
  220. ${If} $0 > 1024
  221. ${OrIf} $0 < 0
  222. System::Int64Op $0 / 1024
  223. Pop $0
  224. StrCpy $1 "gb"
  225. ${EndIf}
  226. ${EndIf}
  227. ${EndIf}
  228. SendMessage $FREESPACE ${WM_SETTEXT} 0 "STR:Free space: $0$1"
  229. FunctionEnd
  230. Function DirChange
  231. Pop $0 # dir hwnd
  232. GetDlgItem $0 $HWNDPARENT 1
  233. System::Call user32::GetWindowText(i$DIRECTORY,t.d,i${NSIS_MAX_STRLEN})
  234. ${If} ${FileExists} $INSTDIR\makensis.exe
  235. EnableWindow $0 1
  236. ${Else}
  237. EnableWindow $0 0
  238. ${EndIf}
  239. Call UpdateFreeSpace
  240. FunctionEnd
  241. Section
  242. SectionEnd