home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 March / PCWMAR09.iso / Software / Freeware / NSIS 2.41 / nsis-2.41-setup.exe / Include / nsDialogs.nsh < prev    next >
Encoding:
Text File  |  2008-08-15  |  21.1 KB  |  802 lines

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