nsDialogs.nsh 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860
  1. /*
  2. nsDialogs.nsh
  3. Header file for creating custom installer pages with nsDialogs
  4. */
  5. !ifndef NSDIALOGS_INCLUDED
  6. !define NSDIALOGS_INCLUDED
  7. !verbose push
  8. !verbose 3
  9. !include LogicLib.nsh
  10. !include WinMessages.nsh
  11. !define WS_EX_DLGMODALFRAME 0x00000001
  12. !define WS_EX_NOPARENTNOTIFY 0x00000004
  13. !define WS_EX_TOPMOST 0x00000008
  14. !define WS_EX_ACCEPTFILES 0x00000010
  15. !define WS_EX_TRANSPARENT 0x00000020
  16. !define WS_EX_MDICHILD 0x00000040
  17. !define WS_EX_TOOLWINDOW 0x00000080
  18. !define WS_EX_WINDOWEDGE 0x00000100
  19. !define WS_EX_CLIENTEDGE 0x00000200
  20. !define WS_EX_CONTEXTHELP 0x00000400
  21. !define WS_EX_RIGHT 0x00001000
  22. !define WS_EX_LEFT 0x00000000
  23. !define WS_EX_RTLREADING 0x00002000
  24. !define WS_EX_LTRREADING 0x00000000
  25. !define WS_EX_LEFTSCROLLBAR 0x00004000
  26. !define WS_EX_RIGHTSCROLLBAR 0x00000000
  27. !define WS_EX_CONTROLPARENT 0x00010000
  28. !define WS_EX_STATICEDGE 0x00020000
  29. !define WS_EX_APPWINDOW 0x00040000
  30. !define WS_CHILD 0x40000000
  31. !define WS_VISIBLE 0x10000000
  32. !define WS_DISABLED 0x08000000
  33. !define WS_CLIPSIBLINGS 0x04000000
  34. !define WS_CLIPCHILDREN 0x02000000
  35. !define WS_MAXIMIZE 0x01000000
  36. !define WS_VSCROLL 0x00200000
  37. !define WS_HSCROLL 0x00100000
  38. !define WS_GROUP 0x00020000
  39. !define WS_TABSTOP 0x00010000
  40. !define ES_LEFT 0x00000000
  41. !define ES_CENTER 0x00000001
  42. !define ES_RIGHT 0x00000002
  43. !define ES_MULTILINE 0x00000004
  44. !define ES_UPPERCASE 0x00000008
  45. !define ES_LOWERCASE 0x00000010
  46. !define ES_PASSWORD 0x00000020
  47. !define ES_AUTOVSCROLL 0x00000040
  48. !define ES_AUTOHSCROLL 0x00000080
  49. !define ES_NOHIDESEL 0x00000100
  50. !define ES_OEMCONVERT 0x00000400
  51. !define ES_READONLY 0x00000800
  52. !define ES_WANTRETURN 0x00001000
  53. !define ES_NUMBER 0x00002000
  54. !define SS_LEFT 0x00000000
  55. !define SS_CENTER 0x00000001
  56. !define SS_RIGHT 0x00000002
  57. !define SS_ICON 0x00000003
  58. !define SS_BLACKRECT 0x00000004
  59. !define SS_GRAYRECT 0x00000005
  60. !define SS_WHITERECT 0x00000006
  61. !define SS_BLACKFRAME 0x00000007
  62. !define SS_GRAYFRAME 0x00000008
  63. !define SS_WHITEFRAME 0x00000009
  64. !define SS_USERITEM 0x0000000A
  65. !define SS_SIMPLE 0x0000000B
  66. !define SS_LEFTNOWORDWRAP 0x0000000C
  67. !define SS_OWNERDRAW 0x0000000D
  68. !define SS_BITMAP 0x0000000E
  69. !define SS_ENHMETAFILE 0x0000000F
  70. !define SS_ETCHEDHORZ 0x00000010
  71. !define SS_ETCHEDVERT 0x00000011
  72. !define SS_ETCHEDFRAME 0x00000012
  73. !define SS_TYPEMASK 0x0000001F
  74. !define SS_REALSIZECONTROL 0x00000040
  75. !define SS_NOPREFIX 0x00000080
  76. !define SS_NOTIFY 0x00000100
  77. !define SS_CENTERIMAGE 0x00000200
  78. !define SS_RIGHTJUST 0x00000400
  79. !define SS_REALSIZEIMAGE 0x00000800
  80. !define SS_SUNKEN 0x00001000
  81. !define SS_EDITCONTROL 0x00002000
  82. !define SS_ENDELLIPSIS 0x00004000
  83. !define SS_PATHELLIPSIS 0x00008000
  84. !define SS_WORDELLIPSIS 0x0000C000
  85. !define SS_ELLIPSISMASK 0x0000C000
  86. !define BS_PUSHBUTTON 0x00000000
  87. !define BS_DEFPUSHBUTTON 0x00000001
  88. !define BS_CHECKBOX 0x00000002
  89. !define BS_AUTOCHECKBOX 0x00000003
  90. !define BS_RADIOBUTTON 0x00000004
  91. !define BS_3STATE 0x00000005
  92. !define BS_AUTO3STATE 0x00000006
  93. !define BS_GROUPBOX 0x00000007
  94. !define BS_USERBUTTON 0x00000008
  95. !define BS_AUTORADIOBUTTON 0x00000009
  96. !define BS_PUSHBOX 0x0000000A
  97. !define BS_OWNERDRAW 0x0000000B
  98. !define BS_TYPEMASK 0x0000000F
  99. !define BS_LEFTTEXT 0x00000020
  100. !define BS_TEXT 0x00000000
  101. !define BS_ICON 0x00000040
  102. !define BS_BITMAP 0x00000080
  103. !define BS_LEFT 0x00000100
  104. !define BS_RIGHT 0x00000200
  105. !define BS_CENTER 0x00000300
  106. !define BS_TOP 0x00000400
  107. !define BS_BOTTOM 0x00000800
  108. !define BS_VCENTER 0x00000C00
  109. !define BS_PUSHLIKE 0x00001000
  110. !define BS_MULTILINE 0x00002000
  111. !define BS_NOTIFY 0x00004000
  112. !define BS_FLAT 0x00008000
  113. !define BS_RIGHTBUTTON ${BS_LEFTTEXT}
  114. !define CBS_SIMPLE 0x0001
  115. !define CBS_DROPDOWN 0x0002
  116. !define CBS_DROPDOWNLIST 0x0003
  117. !define CBS_OWNERDRAWFIXED 0x0010
  118. !define CBS_OWNERDRAWVARIABLE 0x0020
  119. !define CBS_AUTOHSCROLL 0x0040
  120. !define CBS_OEMCONVERT 0x0080
  121. !define CBS_SORT 0x0100
  122. !define CBS_HASSTRINGS 0x0200
  123. !define CBS_NOINTEGRALHEIGHT 0x0400
  124. !define CBS_DISABLENOSCROLL 0x0800
  125. !define CBS_UPPERCASE 0x2000
  126. !define CBS_LOWERCASE 0x4000
  127. !define LBS_NOTIFY 0x0001
  128. !define LBS_SORT 0x0002
  129. !define LBS_NOREDRAW 0x0004
  130. !define LBS_MULTIPLESEL 0x0008
  131. !define LBS_OWNERDRAWFIXED 0x0010
  132. !define LBS_OWNERDRAWVARIABLE 0x0020
  133. !define LBS_HASSTRINGS 0x0040
  134. !define LBS_USETABSTOPS 0x0080
  135. !define LBS_NOINTEGRALHEIGHT 0x0100
  136. !define LBS_MULTICOLUMN 0x0200
  137. !define LBS_WANTKEYBOARDINPUT 0x0400
  138. !define LBS_EXTENDEDSEL 0x0800
  139. !define LBS_DISABLENOSCROLL 0x1000
  140. !define LBS_NODATA 0x2000
  141. !define LBS_NOSEL 0x4000
  142. !define LBS_COMBOBOX 0x8000
  143. !define LR_DEFAULTCOLOR 0x0000
  144. !define LR_MONOCHROME 0x0001
  145. !define LR_COLOR 0x0002
  146. !define LR_COPYRETURNORG 0x0004
  147. !define LR_COPYDELETEORG 0x0008
  148. !define LR_LOADFROMFILE 0x0010
  149. !define LR_LOADTRANSPARENT 0x0020
  150. !define LR_DEFAULTSIZE 0x0040
  151. !define LR_VGACOLOR 0x0080
  152. !define LR_LOADMAP3DCOLORS 0x1000
  153. !define LR_CREATEDIBSECTION 0x2000
  154. !define LR_COPYFROMRESOURCE 0x4000
  155. !define LR_SHARED 0x8000
  156. !define IMAGE_BITMAP 0
  157. !define IMAGE_ICON 1
  158. !define IMAGE_CURSOR 2
  159. !define IMAGE_ENHMETAFILE 3
  160. !define GWL_STYLE -16
  161. !define GWL_EXSTYLE -20
  162. !define DEFAULT_STYLES ${WS_CHILD}|${WS_VISIBLE}|${WS_CLIPSIBLINGS}
  163. !define __NSD_HLine_CLASS STATIC
  164. !define __NSD_HLine_STYLE ${DEFAULT_STYLES}|${SS_ETCHEDHORZ}|${SS_SUNKEN}
  165. !define __NSD_HLine_EXSTYLE ${WS_EX_TRANSPARENT}
  166. !define __NSD_VLine_CLASS STATIC
  167. !define __NSD_VLine_STYLE ${DEFAULT_STYLES}|${SS_ETCHEDVERT}|${SS_SUNKEN}
  168. !define __NSD_VLine_EXSTYLE ${WS_EX_TRANSPARENT}
  169. !define __NSD_Label_CLASS STATIC
  170. !define __NSD_Label_STYLE ${DEFAULT_STYLES}|${SS_NOTIFY}
  171. !define __NSD_Label_EXSTYLE ${WS_EX_TRANSPARENT}
  172. !define __NSD_Icon_CLASS STATIC
  173. !define __NSD_Icon_STYLE ${DEFAULT_STYLES}|${SS_ICON}|${SS_NOTIFY}
  174. !define __NSD_Icon_EXSTYLE 0
  175. !define __NSD_Bitmap_CLASS STATIC
  176. !define __NSD_Bitmap_STYLE ${DEFAULT_STYLES}|${SS_BITMAP}|${SS_NOTIFY}
  177. !define __NSD_Bitmap_EXSTYLE 0
  178. !define __NSD_BrowseButton_CLASS BUTTON
  179. !define __NSD_BrowseButton_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}
  180. !define __NSD_BrowseButton_EXSTYLE 0
  181. !define __NSD_Link_CLASS LINK
  182. !define __NSD_Link_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${BS_OWNERDRAW}
  183. !define __NSD_Link_EXSTYLE 0
  184. !define __NSD_Button_CLASS BUTTON
  185. !define __NSD_Button_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}
  186. !define __NSD_Button_EXSTYLE 0
  187. !define __NSD_GroupBox_CLASS BUTTON
  188. !define __NSD_GroupBox_STYLE ${DEFAULT_STYLES}|${BS_GROUPBOX}
  189. !define __NSD_GroupBox_EXSTYLE ${WS_EX_TRANSPARENT}
  190. !define __NSD_CheckBox_CLASS BUTTON
  191. !define __NSD_CheckBox_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${BS_TEXT}|${BS_VCENTER}|${BS_AUTOCHECKBOX}|${BS_MULTILINE}
  192. !define __NSD_CheckBox_EXSTYLE 0
  193. !define __NSD_RadioButton_CLASS BUTTON
  194. !define __NSD_RadioButton_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${BS_TEXT}|${BS_VCENTER}|${BS_AUTORADIOBUTTON}|${BS_MULTILINE}
  195. !define __NSD_RadioButton_EXSTYLE 0
  196. !define __NSD_Text_CLASS EDIT
  197. !define __NSD_Text_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${ES_AUTOHSCROLL}
  198. !define __NSD_Text_EXSTYLE ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE}
  199. !define __NSD_Password_CLASS EDIT
  200. !define __NSD_Password_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${ES_AUTOHSCROLL}|${ES_PASSWORD}
  201. !define __NSD_Password_EXSTYLE ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE}
  202. !define __NSD_Number_CLASS EDIT
  203. !define __NSD_Number_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${ES_AUTOHSCROLL}|${ES_NUMBER}
  204. !define __NSD_Number_EXSTYLE ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE}
  205. !define __NSD_FileRequest_CLASS EDIT
  206. !define __NSD_FileRequest_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${ES_AUTOHSCROLL}
  207. !define __NSD_FileRequest_EXSTYLE ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE}
  208. !define __NSD_DirRequest_CLASS EDIT
  209. !define __NSD_DirRequest_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${ES_AUTOHSCROLL}
  210. !define __NSD_DirRequest_EXSTYLE ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE}
  211. !define __NSD_ComboBox_CLASS COMBOBOX
  212. !define __NSD_ComboBox_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${WS_VSCROLL}|${WS_CLIPCHILDREN}|${CBS_AUTOHSCROLL}|${CBS_HASSTRINGS}|${CBS_DROPDOWN}
  213. !define __NSD_ComboBox_EXSTYLE ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE}
  214. !define __NSD_DropList_CLASS COMBOBOX
  215. !define __NSD_DropList_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${WS_VSCROLL}|${WS_CLIPCHILDREN}|${CBS_AUTOHSCROLL}|${CBS_HASSTRINGS}|${CBS_DROPDOWNLIST}
  216. !define __NSD_DropList_EXSTYLE ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE}
  217. !define __NSD_ListBox_CLASS LISTBOX
  218. !define __NSD_ListBox_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${WS_VSCROLL}|${LBS_DISABLENOSCROLL}|${LBS_HASSTRINGS}|${LBS_NOINTEGRALHEIGHT}|${LBS_NOTIFY}
  219. !define __NSD_ListBox_EXSTYLE ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE}
  220. !define __NSD_ProgressBar_CLASS msctls_progress32
  221. !define __NSD_ProgressBar_STYLE ${DEFAULT_STYLES}
  222. !define __NSD_ProgressBar_EXSTYLE ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE}
  223. !macro __NSD_DefineControl NAME
  224. !define NSD_Create${NAME} "nsDialogs::CreateControl ${__NSD_${Name}_CLASS} ${__NSD_${Name}_STYLE} ${__NSD_${Name}_EXSTYLE}"
  225. !macroend
  226. !insertmacro __NSD_DefineControl HLine
  227. !insertmacro __NSD_DefineControl VLine
  228. !insertmacro __NSD_DefineControl Label
  229. !insertmacro __NSD_DefineControl Icon
  230. !insertmacro __NSD_DefineControl Bitmap
  231. !insertmacro __NSD_DefineControl BrowseButton
  232. !insertmacro __NSD_DefineControl Link
  233. !insertmacro __NSD_DefineControl Button
  234. !insertmacro __NSD_DefineControl GroupBox
  235. !insertmacro __NSD_DefineControl CheckBox
  236. !insertmacro __NSD_DefineControl RadioButton
  237. !insertmacro __NSD_DefineControl Text
  238. !insertmacro __NSD_DefineControl Password
  239. !insertmacro __NSD_DefineControl Number
  240. !insertmacro __NSD_DefineControl FileRequest
  241. !insertmacro __NSD_DefineControl DirRequest
  242. !insertmacro __NSD_DefineControl ComboBox
  243. !insertmacro __NSD_DefineControl DropList
  244. !insertmacro __NSD_DefineControl ListBox
  245. !insertmacro __NSD_DefineControl ProgressBar
  246. !macro __NSD_OnControlEvent EVENT HWND FUNCTION
  247. Push $0
  248. Push $1
  249. StrCpy $1 "${HWND}"
  250. GetFunctionAddress $0 "${FUNCTION}"
  251. nsDialogs::On${EVENT} $1 $0
  252. Pop $1
  253. Pop $0
  254. !macroend
  255. !macro __NSD_DefineControlCallback EVENT
  256. !define NSD_On${EVENT} `!insertmacro __NSD_OnControlEvent ${EVENT}`
  257. !macroend
  258. !macro __NSD_OnDialogEvent EVENT FUNCTION
  259. Push $0
  260. GetFunctionAddress $0 "${FUNCTION}"
  261. nsDialogs::On${EVENT} $0
  262. Pop $0
  263. !macroend
  264. !macro __NSD_DefineDialogCallback EVENT
  265. !define NSD_On${EVENT} `!insertmacro __NSD_OnDialogEvent ${EVENT}`
  266. !macroend
  267. !insertmacro __NSD_DefineControlCallback Click
  268. !insertmacro __NSD_DefineControlCallback Change
  269. !insertmacro __NSD_DefineControlCallback Notify
  270. !insertmacro __NSD_DefineDialogCallback Back
  271. !macro _NSD_CreateTimer FUNCTION INTERVAL
  272. Push $0
  273. GetFunctionAddress $0 "${FUNCTION}"
  274. nsDialogs::CreateTimer $0 "${INTERVAL}"
  275. Pop $0
  276. !macroend
  277. !define NSD_CreateTimer `!insertmacro _NSD_CreateTimer`
  278. !macro _NSD_KillTimer FUNCTION
  279. Push $0
  280. GetFunctionAddress $0 "${FUNCTION}"
  281. nsDialogs::KillTimer $0
  282. Pop $0
  283. !macroend
  284. !define NSD_KillTimer `!insertmacro _NSD_KillTimer`
  285. !macro _NSD_AddStyle CONTROL STYLE
  286. Push $0
  287. System::Call "user32::GetWindowLong(i ${CONTROL}, i ${GWL_STYLE}) i .r0"
  288. System::Call "user32::SetWindowLong(i ${CONTROL}, i ${GWL_STYLE}, i $0|${STYLE})"
  289. Pop $0
  290. !macroend
  291. !define NSD_AddStyle "!insertmacro _NSD_AddStyle"
  292. !macro _NSD_AddExStyle CONTROL EXSTYLE
  293. Push $0
  294. System::Call "user32::GetWindowLong(i ${CONTROL}, i ${GWL_EXSTYLE}) i .r0"
  295. System::Call "user32::SetWindowLong(i ${CONTROL}, i ${GWL_EXSTYLE}, i $0|${EXSTYLE})"
  296. Pop $0
  297. !macroend
  298. !define NSD_AddExStyle "!insertmacro _NSD_AddExStyle"
  299. !macro __NSD_GetText CONTROL VAR
  300. System::Call user32::GetWindowText(i${CONTROL},t.s,i${NSIS_MAX_STRLEN})
  301. Pop ${VAR}
  302. !macroend
  303. !define NSD_GetText `!insertmacro __NSD_GetText`
  304. !macro __NSD_SetText CONTROL TEXT
  305. SendMessage ${CONTROL} ${WM_SETTEXT} 0 `STR:${TEXT}`
  306. !macroend
  307. !define NSD_SetText `!insertmacro __NSD_SetText`
  308. !macro _NSD_SetTextLimit CONTROL LIMIT
  309. SendMessage ${CONTROL} ${EM_SETLIMITTEXT} ${LIMIT} 0
  310. !macroend
  311. !define NSD_SetTextLimit "!insertmacro _NSD_SetTextLimit"
  312. !macro __NSD_GetState CONTROL VAR
  313. SendMessage ${CONTROL} ${BM_GETCHECK} 0 0 ${VAR}
  314. !macroend
  315. !define NSD_GetState `!insertmacro __NSD_GetState`
  316. !macro __NSD_SetState CONTROL STATE
  317. SendMessage ${CONTROL} ${BM_SETCHECK} ${STATE} 0
  318. !macroend
  319. !define NSD_SetState `!insertmacro __NSD_SetState`
  320. !macro __NSD_Check CONTROL
  321. ${NSD_SetState} ${CONTROL} ${BST_CHECKED}
  322. !macroend
  323. !define NSD_Check `!insertmacro __NSD_Check`
  324. !macro __NSD_Uncheck CONTROL
  325. ${NSD_SetState} ${CONTROL} ${BST_UNCHECKED}
  326. !macroend
  327. !define NSD_Uncheck `!insertmacro __NSD_Uncheck`
  328. !macro __NSD_SetFocus HWND
  329. System::Call "user32::SetFocus(i${HWND})"
  330. !macroend
  331. !define NSD_SetFocus `!insertmacro __NSD_SetFocus`
  332. !macro _NSD_CB_AddString CONTROL STRING
  333. SendMessage ${CONTROL} ${CB_ADDSTRING} 0 `STR:${STRING}`
  334. !macroend
  335. !define NSD_CB_AddString "!insertmacro _NSD_CB_AddString"
  336. !macro _NSD_CB_SelectString CONTROL STRING
  337. SendMessage ${CONTROL} ${CB_SELECTSTRING} -1 `STR:${STRING}`
  338. !macroend
  339. !define NSD_CB_SelectString "!insertmacro _NSD_CB_SelectString"
  340. !macro _NSD_LB_AddString CONTROL STRING
  341. SendMessage ${CONTROL} ${LB_ADDSTRING} 0 `STR:${STRING}`
  342. !macroend
  343. !define NSD_LB_AddString "!insertmacro _NSD_LB_AddString"
  344. !macro __NSD_LB_DelString CONTROL STRING
  345. SendMessage ${CONTROL} ${LB_DELETESTRING} 0 `STR:${STRING}`
  346. !macroend
  347. !define NSD_LB_DelString `!insertmacro __NSD_LB_DelString`
  348. !macro __NSD_LB_Clear CONTROL VAR
  349. SendMessage ${CONTROL} ${LB_RESETCONTENT} 0 0 ${VAR}
  350. !macroend
  351. !define NSD_LB_Clear `!insertmacro __NSD_LB_Clear`
  352. !macro __NSD_LB_GetCount CONTROL VAR
  353. SendMessage ${CONTROL} ${LB_GETCOUNT} 0 0 ${VAR}
  354. !macroend
  355. !define NSD_LB_GetCount `!insertmacro __NSD_LB_GetCount`
  356. !macro _NSD_LB_SelectString CONTROL STRING
  357. SendMessage ${CONTROL} ${LB_SELECTSTRING} -1 `STR:${STRING}`
  358. !macroend
  359. !define NSD_LB_SelectString "!insertmacro _NSD_LB_SelectString"
  360. !macro __NSD_LB_GetSelection CONTROL VAR
  361. SendMessage ${CONTROL} ${LB_GETCURSEL} 0 0 ${VAR}
  362. System::Call 'user32::SendMessage(i ${CONTROL}, i ${LB_GETTEXT}, i ${VAR}, t .s)'
  363. Pop ${VAR}
  364. !macroend
  365. !define NSD_LB_GetSelection `!insertmacro __NSD_LB_GetSelection`
  366. !macro __NSD_LoadAndSetImage _LIHINSTMODE _IMGTYPE _LIHINSTSRC _LIFLAGS CONTROL IMAGE HANDLE
  367. Push $0
  368. Push $R0
  369. StrCpy $R0 ${CONTROL} # in case ${CONTROL} is $0
  370. !if "${_LIHINSTMODE}" == "exeresource"
  371. System::Call 'kernel32::GetModuleHandle(i0) i.r0'
  372. !undef _LIHINSTSRC
  373. !define _LIHINSTSRC r0
  374. !endif
  375. System::Call 'user32::LoadImage(i ${_LIHINSTSRC}, ts, i ${_IMGTYPE}, i0, i0, i${_LIFLAGS}) i.r0' "${IMAGE}"
  376. SendMessage $R0 ${STM_SETIMAGE} ${_IMGTYPE} $0
  377. Pop $R0
  378. Exch $0
  379. Pop ${HANDLE}
  380. !macroend
  381. !macro __NSD_SetIconFromExeResource CONTROL IMAGE HANDLE
  382. !insertmacro __NSD_LoadAndSetImage exeresource ${IMAGE_ICON} 0 ${LR_DEFAULTSIZE} "${CONTROL}" "${IMAGE}" ${HANDLE}
  383. !macroend
  384. !macro __NSD_SetIconFromInstaller CONTROL HANDLE
  385. !insertmacro __NSD_SetIconFromExeResource "${CONTROL}" "#103" ${HANDLE}
  386. !macroend
  387. !define NSD_SetImage `!insertmacro __NSD_LoadAndSetImage file ${IMAGE_BITMAP} 0 "${LR_LOADFROMFILE}"`
  388. !define NSD_SetBitmap `${NSD_SetImage}`
  389. !define NSD_SetIcon `!insertmacro __NSD_LoadAndSetImage file ${IMAGE_ICON} 0 "${LR_LOADFROMFILE}|${LR_DEFAULTSIZE}"`
  390. !define NSD_SetIconFromExeResource `!insertmacro __NSD_SetIconFromExeResource`
  391. !define NSD_SetIconFromInstaller `!insertmacro __NSD_SetIconFromInstaller`
  392. !macro __NSD_SetStretchedImage CONTROL IMAGE HANDLE
  393. Push $0
  394. Push $1
  395. Push $2
  396. Push $R0
  397. StrCpy $R0 ${CONTROL} # in case ${CONTROL} is $0
  398. StrCpy $1 ""
  399. StrCpy $2 ""
  400. System::Call '*(i, i, i, i) i.s'
  401. Pop $0
  402. ${If} $0 <> 0
  403. System::Call 'user32::GetClientRect(iR0, ir0)'
  404. System::Call '*$0(i, i, i .s, i .s)'
  405. System::Free $0
  406. Pop $1
  407. Pop $2
  408. ${EndIf}
  409. System::Call 'user32::LoadImage(i0, ts, i ${IMAGE_BITMAP}, ir1, ir2, i${LR_LOADFROMFILE}) i.s' "${IMAGE}"
  410. Pop $0
  411. SendMessage $R0 ${STM_SETIMAGE} ${IMAGE_BITMAP} $0
  412. Pop $R0
  413. Pop $2
  414. Pop $1
  415. Exch $0
  416. Pop ${HANDLE}
  417. !macroend
  418. !define NSD_SetStretchedImage `!insertmacro __NSD_SetStretchedImage`
  419. !macro __NSD_FreeImage IMAGE
  420. ${If} ${IMAGE} <> 0
  421. System::Call gdi32::DeleteObject(is) ${IMAGE}
  422. ${EndIf}
  423. !macroend
  424. !define NSD_FreeImage `!insertmacro __NSD_FreeImage`
  425. !define NSD_FreeBitmap `${NSD_FreeImage}`
  426. !macro __NSD_FreeIcon IMAGE
  427. System::Call user32::DestroyIcon(is) ${IMAGE}
  428. !macroend
  429. !define NSD_FreeIcon `!insertmacro __NSD_FreeIcon`
  430. !macro __NSD_ClearImage _IMGTYPE CONTROL
  431. SendMessage ${CONTROL} ${STM_SETIMAGE} ${_IMGTYPE} 0
  432. !macroend
  433. !define NSD_ClearImage `!insertmacro __NSD_ClearImage ${IMAGE_BITMAP}`
  434. !define NSD_ClearIcon `!insertmacro __NSD_ClearImage ${IMAGE_ICON}`
  435. !define DEBUG `System::Call kernel32::OutputDebugString(ts)`
  436. !macro __NSD_ControlCase TYPE
  437. ${Case} ${TYPE}
  438. ${NSD_Create${TYPE}} $R3u $R4u $R5u $R6u $R7
  439. Pop $R9
  440. ${Break}
  441. !macroend
  442. !macro __NSD_ControlCaseEx TYPE
  443. ${Case} ${TYPE}
  444. Call ${TYPE}
  445. ${Break}
  446. !macroend
  447. !macro NSD_FUNCTION_INIFILE
  448. !insertmacro NSD_INIFILE ""
  449. !macroend
  450. !macro NSD_UNFUNCTION_INIFILE
  451. !insertmacro NSD_INIFILE un.
  452. !macroend
  453. !macro NSD_INIFILE UNINSTALLER_FUNCPREFIX
  454. ;Functions to create dialogs based on old InstallOptions INI files
  455. Function ${UNINSTALLER_FUNCPREFIX}CreateDialogFromINI
  456. # $0 = ini
  457. ReadINIStr $R0 $0 Settings RECT
  458. ${If} $R0 == ""
  459. StrCpy $R0 1018
  460. ${EndIf}
  461. nsDialogs::Create $R0
  462. Pop $R9
  463. ReadINIStr $R0 $0 Settings RTL
  464. nsDialogs::SetRTL $R0
  465. ReadINIStr $R0 $0 Settings NumFields
  466. ${DEBUG} "NumFields = $R0"
  467. ${For} $R1 1 $R0
  468. ${DEBUG} "Creating field $R1"
  469. ReadINIStr $R2 $0 "Field $R1" Type
  470. ${DEBUG} " Type = $R2"
  471. ReadINIStr $R3 $0 "Field $R1" Left
  472. ${DEBUG} " Left = $R3"
  473. ReadINIStr $R4 $0 "Field $R1" Top
  474. ${DEBUG} " Top = $R4"
  475. ReadINIStr $R5 $0 "Field $R1" Right
  476. ${DEBUG} " Right = $R5"
  477. ReadINIStr $R6 $0 "Field $R1" Bottom
  478. ${DEBUG} " Bottom = $R6"
  479. IntOp $R5 $R5 - $R3
  480. ${DEBUG} " Width = $R5"
  481. IntOp $R6 $R6 - $R4
  482. ${DEBUG} " Height = $R6"
  483. ReadINIStr $R7 $0 "Field $R1" Text
  484. ${DEBUG} " Text = $R7"
  485. ${Switch} $R2
  486. !insertmacro __NSD_ControlCase HLine
  487. !insertmacro __NSD_ControlCase VLine
  488. !insertmacro __NSD_ControlCase Label
  489. !insertmacro __NSD_ControlCase Icon
  490. !insertmacro __NSD_ControlCase Bitmap
  491. !insertmacro __NSD_ControlCaseEx Link
  492. !insertmacro __NSD_ControlCase Button
  493. !insertmacro __NSD_ControlCase GroupBox
  494. !insertmacro __NSD_ControlCase CheckBox
  495. !insertmacro __NSD_ControlCase RadioButton
  496. !insertmacro __NSD_ControlCase Text
  497. !insertmacro __NSD_ControlCase Password
  498. !insertmacro __NSD_ControlCaseEx FileRequest
  499. !insertmacro __NSD_ControlCaseEx DirRequest
  500. !insertmacro __NSD_ControlCase ComboBox
  501. !insertmacro __NSD_ControlCase DropList
  502. !insertmacro __NSD_ControlCase ListBox
  503. ${EndSwitch}
  504. WriteINIStr $0 "Field $R1" HWND $R9
  505. ${Next}
  506. nsDialogs::Show
  507. FunctionEnd
  508. Function ${UNINSTALLER_FUNCPREFIX}UpdateINIState
  509. ${DEBUG} "Updating INI state"
  510. ReadINIStr $R0 $0 Settings NumFields
  511. ${DEBUG} "NumField = $R0"
  512. ${For} $R1 1 $R0
  513. ReadINIStr $R2 $0 "Field $R1" HWND
  514. ReadINIStr $R3 $0 "Field $R1" "Type"
  515. ${Switch} $R3
  516. ${Case} "CheckBox"
  517. ${Case} "RadioButton"
  518. ${DEBUG} " HWND = $R2"
  519. ${NSD_GetState} $R2 $R2
  520. ${DEBUG} " Window selection = $R2"
  521. ${Break}
  522. ${CaseElse}
  523. ${DEBUG} " HWND = $R2"
  524. ${NSD_GetText} $R2 $R2
  525. ${DEBUG} " Window text = $R2"
  526. ${Break}
  527. ${EndSwitch}
  528. WriteINIStr $0 "Field $R1" STATE $R2
  529. ${Next}
  530. FunctionEnd
  531. Function ${UNINSTALLER_FUNCPREFIX}FileRequest
  532. IntOp $R5 $R5 - 15
  533. IntOp $R8 $R3 + $R5
  534. ${NSD_CreateBrowseButton} $R8u $R4u 15u $R6u ...
  535. Pop $R8
  536. nsDialogs::SetUserData $R8 $R1 # remember field id
  537. WriteINIStr $0 "Field $R1" HWND2 $R8
  538. ${NSD_OnClick} $R8 ${UNINSTALLER_FUNCPREFIX}OnFileBrowseButton
  539. ReadINIStr $R9 $0 "Field $R1" State
  540. ${NSD_CreateFileRequest} $R3u $R4u $R5u $R6u $R9
  541. Pop $R9
  542. FunctionEnd
  543. Function ${UNINSTALLER_FUNCPREFIX}DirRequest
  544. IntOp $R5 $R5 - 15
  545. IntOp $R8 $R3 + $R5
  546. ${NSD_CreateBrowseButton} $R8u $R4u 15u $R6u ...
  547. Pop $R8
  548. nsDialogs::SetUserData $R8 $R1 # remember field id
  549. WriteINIStr $0 "Field $R1" HWND2 $R8
  550. ${NSD_OnClick} $R8 ${UNINSTALLER_FUNCPREFIX}OnDirBrowseButton
  551. ReadINIStr $R9 $0 "Field $R1" State
  552. ${NSD_CreateFileRequest} $R3u $R4u $R5u $R6u $R9
  553. Pop $R9
  554. FunctionEnd
  555. Function ${UNINSTALLER_FUNCPREFIX}OnFileBrowseButton
  556. Pop $R0
  557. nsDialogs::GetUserData $R0
  558. Pop $R1
  559. ReadINIStr $R2 $0 "Field $R1" HWND
  560. ReadINIStr $R4 $0 "Field $R1" Filter
  561. ${NSD_GetText} $R2 $R3
  562. nsDialogs::SelectFileDialog save $R3 $R4
  563. Pop $R3
  564. ${If} $R3 != ""
  565. SendMessage $R2 ${WM_SETTEXT} 0 STR:$R3
  566. ${EndIf}
  567. FunctionEnd
  568. Function ${UNINSTALLER_FUNCPREFIX}OnDirBrowseButton
  569. Pop $R0
  570. nsDialogs::GetUserData $R0
  571. Pop $R1
  572. ReadINIStr $R2 $0 "Field $R1" HWND
  573. ReadINIStr $R3 $0 "Field $R1" Text
  574. ${NSD_GetText} $R2 $R4
  575. nsDialogs::SelectFolderDialog $R3 $R4
  576. Pop $R3
  577. ${If} $R3 != error
  578. SendMessage $R2 ${WM_SETTEXT} 0 STR:$R3
  579. ${EndIf}
  580. FunctionEnd
  581. Function ${UNINSTALLER_FUNCPREFIX}Link
  582. ${NSD_CreateLink} $R3u $R4u $R5u $R6u $R7
  583. Pop $R9
  584. nsDialogs::SetUserData $R9 $R1 # remember field id
  585. ${NSD_OnClick} $R9 ${UNINSTALLER_FUNCPREFIX}OnLink
  586. FunctionEnd
  587. Function ${UNINSTALLER_FUNCPREFIX}OnLink
  588. Pop $R0
  589. nsDialogs::GetUserData $R0
  590. Pop $R1
  591. ReadINIStr $R1 $0 "Field $R1" STATE
  592. ExecShell "" $R1
  593. FunctionEnd
  594. !macroend
  595. !verbose pop
  596. !endif