nsWindows.nsh 29 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121
  1. /*
  2. nsWindows.nsh
  3. Header file for creating custom installer pages with nsWindows
  4. */
  5. !ifndef NSWINDOWS_INCLUDED
  6. !define NSWINDOWS_INCLUDED
  7. !verbose push
  8. !verbose 3
  9. !include nsDialogs.nsh
  10. !include Colors.nsh
  11. ;hWndInsertAfter:
  12. !define HWND_TOP 0
  13. !define HWND_BOTTOM 1
  14. !define HWND_TOPMOST -1
  15. !define HWND_NOTOPMOST -2
  16. ;uFlags :
  17. !define SWP_NOSIZE 0x0001
  18. !define SWP_NOMOVE 0x0002
  19. !define SWP_NOZORDER 0x0004
  20. !define SWP_NOREDRAW 0x0008
  21. !define SWP_NOACTIVATE 0x0010
  22. !define SWP_FRAMECHANGED 0x0020 /* The frame changed: send WM_NCCALCSIZE */
  23. !define SWP_SHOWWINDOW 0x0040
  24. !define SWP_HIDEWINDOW 0x0080
  25. !define SWP_NOCOPYBITS 0x0100
  26. !define SWP_NOOWNERZORDER 0x0200 /* Don't do owner Z ordering */
  27. !define SWP_NOSENDCHANGING 0x0400 /* Don't send WM_WINDOWPOSCHANGING */
  28. !define SWP_DRAWFRAME ${SWP_FRAMECHANGED}
  29. !define SWP_NOREPOSITION ${SWP_NOOWNERZORDER}
  30. !define SWP_DEFERERASE 0x2000
  31. !define SWP_ASYNCWINDOWPOS 0x4000
  32. /*
  33. * Window sTYLES
  34. */
  35. ;dwStyle:
  36. !define WS_OVERLAPPED 0x00000000
  37. !define WS_POPUP 0x80000000
  38. !define WS_CAPTION 0x00C00000 /* WS_BORDER | WS_DLGFRAME */
  39. !define WS_MINIMIZE 0x20000000
  40. ;!define WS_VISIBLE 0x10000000
  41. ;!define WS_DISABLED 0x08000000
  42. ;!define WS_CLIPSIBLINGS 0x04000000
  43. ;!define WS_CLIPCHILDREN 0x02000000
  44. ;!define WS_MAXIMIZE 0x01000000
  45. ;!define WS_CHILD 0x40000000
  46. !define WS_BORDER 0x00800000
  47. !define WS_DLGFRAME 0x00400000
  48. ;!define WS_VSCROLL 0x00200000
  49. ;!define WS_HSCROLL 0x00100000
  50. !define WS_SYSMENU 0x00080000
  51. !define WS_THICKFRAME 0x00040000
  52. ;!define WS_GROUP 0x00020000
  53. ;!define WS_TABSTOP 0x00010000
  54. !define WS_MINIMIZEBOX 0x00020000
  55. !define WS_MAXIMIZEBOX 0x00010000
  56. !define WS_TILED ${WS_OVERLAPPED}
  57. !define WS_ICONIC ${WS_MINIMIZE}
  58. !define WS_SIZEBOX ${WS_THICKFRAME}
  59. !define WS_TILEDWINDOW ${WS_OVERLAPPEDWINDOW}
  60. /*
  61. * Common Window Styles
  62. */
  63. !define WS_OVERLAPPEDWINDOW ${WS_OVERLAPPED}|${WS_CAPTION}|${WS_SYSMENU}|${WS_THICKFRAME}|${WS_MINIMIZEBOX}|${WS_MAXIMIZEBOX}
  64. !define WS_POPUPWINDOW ${WS_POPUP}|${WS_BORDER}|${WS_SYSMENU}
  65. !define WS_CHILDWINDOW ${WS_CHILD}
  66. !define WS_EX_OVERLAPPEDWINDOW ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE}
  67. !define WS_EX_PALETTEWINDOW ${WS_EX_WINDOWEDGE}|${WS_EX_TOOLWINDOW}|${WS_EX_TOPMOST}
  68. ; /* WINVER >= 0x0400 */
  69. ;(_WIN32_WINNT >= 0x0500)
  70. !define WS_EX_LAYERED 0x00080000
  71. !define WS_EX_NOINHERITLAYOUT 0x00100000 ; Disable inheritence of mirroring by children
  72. !define WS_EX_LAYOUTRTL 0x00400000 ; Right to left mirroring
  73. ; /* WINVER >= 0x0500 */
  74. ;(_WIN32_WINNT >= 0x0501)
  75. !define WS_EX_COMPOSITED 0x02000000
  76. ; /* _WIN32_WINNT >= 0x0501 */
  77. ;(_WIN32_WINNT >= 0x0500)
  78. !define WS_EX_NOACTIVATE 0x08000000
  79. ; /* _WIN32_WINNT >= 0x0500 */
  80. !define __NSW_HLine_CLASS STATIC
  81. !define __NSW_HLine_STYLE ${DEFAULT_STYLES}|${SS_ETCHEDHORZ}|${SS_SUNKEN}
  82. !define __NSW_HLine_EXSTYLE ${WS_EX_TRANSPARENT}
  83. !define __NSW_VLine_CLASS STATIC
  84. !define __NSW_VLine_STYLE ${DEFAULT_STYLES}|${SS_ETCHEDVERT}|${SS_SUNKEN}
  85. !define __NSW_VLine_EXSTYLE ${WS_EX_TRANSPARENT}
  86. !define __NSW_Label_CLASS STATIC
  87. !define __NSW_Label_STYLE ${DEFAULT_STYLES}|${SS_NOTIFY}
  88. !define __NSW_Label_EXSTYLE ${WS_EX_TRANSPARENT}
  89. !define __NSW_Icon_CLASS STATIC
  90. !define __NSW_Icon_STYLE ${DEFAULT_STYLES}|${SS_ICON}|${SS_NOTIFY}
  91. !define __NSW_Icon_EXSTYLE 0
  92. !define __NSW_Bitmap_CLASS STATIC
  93. !define __NSW_Bitmap_STYLE ${DEFAULT_STYLES}|${SS_BITMAP}|${SS_NOTIFY}
  94. !define __NSW_Bitmap_EXSTYLE 0
  95. !define __NSW_BrowseButton_CLASS BUTTON
  96. !define __NSW_BrowseButton_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}
  97. !define __NSW_BrowseButton_EXSTYLE 0
  98. !define __NSW_Link_CLASS LINK
  99. !define __NSW_Link_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${BS_OWNERDRAW}
  100. !define __NSW_Link_EXSTYLE 0
  101. !define __NSW_Button_CLASS BUTTON
  102. !define __NSW_Button_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}
  103. !define __NSW_Button_EXSTYLE 0
  104. !define __NSW_GroupBox_CLASS BUTTON
  105. !define __NSW_GroupBox_STYLE ${DEFAULT_STYLES}|${BS_GROUPBOX}
  106. !define __NSW_GroupBox_EXSTYLE ${WS_EX_TRANSPARENT}
  107. !define __NSW_CheckBox_CLASS BUTTON
  108. !define __NSW_CheckBox_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${BS_TEXT}|${BS_VCENTER}|${BS_AUTOCHECKBOX}|${BS_MULTILINE}
  109. !define __NSW_CheckBox_EXSTYLE 0
  110. !define __NSW_RadioButton_CLASS BUTTON
  111. !define __NSW_RadioButton_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${BS_TEXT}|${BS_VCENTER}|${BS_AUTORADIOBUTTON}|${BS_MULTILINE}
  112. !define __NSW_RadioButton_EXSTYLE 0
  113. !define __NSW_Text_CLASS EDIT
  114. !define __NSW_Text_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${ES_AUTOHSCROLL}
  115. !define __NSW_Text_EXSTYLE ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE}
  116. !define __NSW_ReadText_CLASS EDIT
  117. !define __NSW_ReadText_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${ES_AUTOHSCROLL}|${ES_READONLY}
  118. !define __NSW_ReadText_EXSTYLE ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE}
  119. !define __NSW_Memo_CLASS EDIT
  120. !define __NSW_Memo_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${ES_AUTOVSCROLL}|${ES_MULTILINE}|${ES_WANTRETURN}|${WS_VSCROLL}
  121. !define __NSW_Memo_EXSTYLE ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE}
  122. !define __NSW_Password_CLASS EDIT
  123. !define __NSW_Password_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${ES_AUTOHSCROLL}|${ES_PASSWORD}
  124. !define __NSW_Password_EXSTYLE ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE}
  125. !define __NSW_Number_CLASS EDIT
  126. !define __NSW_Number_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${ES_AUTOHSCROLL}|${ES_NUMBER}
  127. !define __NSW_Number_EXSTYLE ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE}
  128. !define __NSW_FileRequest_CLASS EDIT
  129. !define __NSW_FileRequest_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${ES_AUTOHSCROLL}
  130. !define __NSW_FileRequest_EXSTYLE ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE}
  131. !define __NSW_DirRequest_CLASS EDIT
  132. !define __NSW_DirRequest_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${ES_AUTOHSCROLL}
  133. !define __NSW_DirRequest_EXSTYLE ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE}
  134. !define __NSW_ComboBox_CLASS COMBOBOX
  135. !define __NSW_ComboBox_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${WS_VSCROLL}|${WS_CLIPCHILDREN}|${CBS_AUTOHSCROLL}|${CBS_HASSTRINGS}|${CBS_DROPDOWN}
  136. !define __NSW_ComboBox_EXSTYLE ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE}
  137. !define __NSW_DropList_CLASS COMBOBOX
  138. !define __NSW_DropList_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${WS_VSCROLL}|${WS_CLIPCHILDREN}|${CBS_AUTOHSCROLL}|${CBS_HASSTRINGS}|${CBS_DROPDOWNLIST}
  139. !define __NSW_DropList_EXSTYLE ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE}
  140. !define __NSW_ListBox_CLASS LISTBOX
  141. !define __NSW_ListBox_STYLE ${DEFAULT_STYLES}|${WS_TABSTOP}|${WS_VSCROLL}|${LBS_DISABLENOSCROLL}|${LBS_HASSTRINGS}|${LBS_NOINTEGRALHEIGHT}|${LBS_NOTIFY}
  142. !define __NSW_ListBox_EXSTYLE ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE}
  143. !define __NSW_ProgressBar_CLASS msctls_progress32
  144. !define __NSW_ProgressBar_STYLE ${DEFAULT_STYLES}
  145. !define __NSW_ProgressBar_EXSTYLE ${WS_EX_WINDOWEDGE}|${WS_EX_CLIENTEDGE}
  146. !macro _NSW_CenterWindow HWND HWPARENT
  147. ; ${nsWindows}::CenterWindow ${HWND} ${HWPARENT}
  148. Push $R0
  149. System::Call /NOUNLOAD "*(i, i, i, i) i.s"
  150. Pop $R0
  151. ;Get placement
  152. System::Call /NOUNLOAD 'User32::GetWindowRect(i, i) i (${HWND}, R0)'
  153. System::Call /NOUNLOAD "*$R0(i .s, i .s, i .s, i .s)"
  154. Pop $0 ;left
  155. Pop $1 ;top
  156. Pop $2 ;right
  157. Pop $3 ;bottom
  158. IntOp $R1 $2 - $0 ;width
  159. IntOp $R2 $3 - $1 ;height
  160. ;Messagebox mb_ok "$$0:$0 $$1:$1 $$2:$2 $$3:$3"
  161. ;Get Parent's placement
  162. System::Call /NOUNLOAD 'User32::GetWindowRect(i, i) i (${HWPARENT}, R0)'
  163. System::Call /NOUNLOAD "*$R0(i .s, i .s, i .s, i .s)"
  164. System::Free $R0
  165. Pop $0 ;parentleft
  166. Pop $1 ;parenttop
  167. Pop $2 ;parentright
  168. Pop $3 ;parentbottom
  169. ;Messagebox mb_ok "$$0:$0 $$1:$1 $$2:$2 $$3:$3"
  170. IntOp $R3 $2 - $0 ;parentwidth
  171. IntOp $R4 $3 - $1 ;parentheight
  172. IntOp $R3 $R3 - $R1 ;width difference
  173. IntOp $R3 $R3 / 2 ;width difference / 2
  174. IntOp $R4 $R4 - $R2 ;height difference
  175. IntOp $R4 $R4 / 2 ;height difference / 2
  176. IntOp $R3 $0 + $R3 ;x /new
  177. IntOp $R4 $1 + $R4 ;y /new
  178. ;${NSW_SetWindowPos} ${HWND} $R3 $R4
  179. System::Call user32::SetWindowPos(i${HWND},i0,i$R3,i$R4,i0,i0,i${SWP_NOSIZE})
  180. Pop $R0
  181. ;Messagebox mb_ok "$$R3:$R3 $$R4:$R4"
  182. !macroend
  183. !define NSW_CenterWindow `!insertmacro _NSW_CenterWindow`
  184. ;add by zhfi
  185. !ifndef dwExStyle
  186. !define dwExStyle ${WS_EX_CLIENTEDGE}|${WS_EX_WINDOWEDGE}
  187. !endif
  188. !ifndef dwStyle
  189. !define dwStyle ${WS_VISIBLE}|${WS_SYSMENU}|${WS_CAPTION}
  190. !endif
  191. var insWindows
  192. var hnsWindows
  193. !macro _NSW_CreateWindow OUTVAR TITLE INTERVAL
  194. IsWindow ${OUTVAR} 0 +3
  195. ShowWindow ${OUTVAR} ${SW_SHOW}
  196. Abort
  197. !ifdef insWindows
  198. !undef insWindows
  199. !endif
  200. !ifdef nsWindows
  201. !undef nsWindows
  202. !endif
  203. IsWindow $hnsWindows 0 +2
  204. IntOp $insWindows $insWindows + 1
  205. !define insWindows $insWindows
  206. !define nsWindows nsWindows${insWindows}
  207. ;
  208. !echo "Generating nsWindows temp plugins..."
  209. !ifndef nsWindows_warning
  210. !warning "Note: nsWindows.dll must be put in NSIS's Plugins Directory!"
  211. !define nsWindows_warning
  212. !endif
  213. !ifdef nsWindows_produce
  214. !undef nsWindows_produce
  215. !endif
  216. !define nsWindows_produce "${NSISDIR}\Plugins\nsWindows_produce.bat"
  217. !appendfile "${nsWindows_produce}" '@echo off$\n'
  218. !appendfile "${nsWindows_produce}" 'del /q "${NSISDIR}\Plugins\nsWindows.tmp\nsWindows*.dll"$\n'
  219. !appendfile "${nsWindows_produce}" 'md "${NSISDIR}\Plugins\nsWindows.tmp\"$\n'
  220. !appendfile "${nsWindows_produce}" 'copy /B /-Y "${NSISDIR}\Plugins\nsWindows.dll" "${NSISDIR}\Plugins\nsWindows.tmp\${nsWindows}.dll"$\n'
  221. !appendfile "${nsWindows_produce}" 'exit$\n'
  222. !execute "${nsWindows_produce}"
  223. !delfile "${nsWindows_produce}"
  224. !undef nsWindows_produce
  225. !echo "Generating finished!"
  226. ;
  227. !AddPluginDir "${NSISDIR}\Plugins\nsWindows.tmp\"
  228. ReserveFile "${NSISDIR}\Plugins\nsWindows.tmp\${nsWindows}.dll"
  229. ${nsWindows}::Create $hwndparent ${dwExStyle} ${dwStyle} "${TITLE}" ${INTERVAL}
  230. Pop ${OUTVAR}
  231. StrCpy $hnsWindows ${OUTVAR}
  232. ShowWindow ${OUTVAR} ${SW_HIDE}
  233. !macroend
  234. !define NSW_CreateWindow `!insertmacro _NSW_CreateWindow`
  235. !macro _NSW_CreateWindowEx OUTVAR HWND ExStyle Style TITLE INTERVAL
  236. IsWindow ${OUTVAR} 0 +3
  237. ShowWindow ${OUTVAR} ${SW_SHOW}
  238. Abort
  239. !ifdef insWindows
  240. !undef insWindows
  241. !endif
  242. !ifdef nsWindows
  243. !undef nsWindows
  244. !endif
  245. IsWindow $hnsWindows 0 +2
  246. IntOp $insWindows $insWindows + 1
  247. !define insWindows $insWindows
  248. !define nsWindows nsWindows${insWindows}
  249. ;
  250. !echo "Generating nsWindows temp plugins..."
  251. !ifndef nsWindows_warning
  252. !warning "Note: nsWindows.dll must be put in NSIS's Plugins Directory!"
  253. !define nsWindows_warning
  254. !endif
  255. !ifdef nsWindows_produce
  256. !undef nsWindows_produce
  257. !endif
  258. !define nsWindows_produce "${NSISDIR}\Plugins\nsWindows_produce.bat"
  259. !appendfile "${nsWindows_produce}" '@echo off$\n'
  260. !appendfile "${nsWindows_produce}" 'del /q "${NSISDIR}\Plugins\nsWindows.tmp\nsWindows*.dll"$\n'
  261. !appendfile "${nsWindows_produce}" 'md "${NSISDIR}\Plugins\nsWindows.tmp\"$\n'
  262. !appendfile "${nsWindows_produce}" 'copy /B /-Y "${NSISDIR}\Plugins\nsWindows.dll" "${NSISDIR}\Plugins\nsWindows.tmp\${nsWindows}.dll"$\n'
  263. !appendfile "${nsWindows_produce}" 'exit$\n'
  264. !execute "${nsWindows_produce}"
  265. !delfile "${nsWindows_produce}"
  266. !undef nsWindows_produce
  267. !echo "Generating finished!"
  268. ;
  269. !AddPluginDir "${NSISDIR}\Plugins\nsWindows.tmp\"
  270. ReserveFile "${NSISDIR}\Plugins\nsWindows.tmp\${nsWindows}.dll"
  271. ${nsWindows}::Create ${HWND} ${ExStyle} ${Style} "${TITLE}" ${INTERVAL}
  272. Pop ${OUTVAR}
  273. StrCpy $hnsWindows ${OUTVAR}
  274. ShowWindow ${OUTVAR} ${SW_HIDE}
  275. !macroend
  276. !define NSW_CreateWindowEx `!insertmacro _NSW_CreateWindowEx`
  277. !macro _NSW_Show
  278. ${nsWindows}::Show
  279. ; IsWindow $hnsWindows 0 +2
  280. ; IntOp $insWindows $insWindows + 1
  281. !echo "Clearing nsWindows temp plugins..."
  282. !ifdef nsWindows_clear
  283. !undef nsWindows_clear
  284. !endif
  285. !define nsWindows_clear "${NSISDIR}\Plugins\nsWindows_clear.bat"
  286. !appendfile "${nsWindows_clear}" '@echo off$\n'
  287. !appendfile "${nsWindows_clear}" 'del /q "${NSISDIR}\Plugins\nsWindows.tmp\nsWindows*.dll"$\n'
  288. !appendfile "${nsWindows_clear}" 'rd /q "${NSISDIR}\Plugins\nsWindows.tmp\"$\n'
  289. !appendfile "${nsWindows_clear}" 'exit$\n'
  290. !execute "${nsWindows_clear}"
  291. !delfile "${nsWindows_clear}"
  292. !undef nsWindows_clear
  293. !echo "Clearing finished!"
  294. !macroend
  295. !define NSW_Show `!insertmacro _NSW_Show`
  296. !macro __NSW_DefineControl NAME
  297. !define NSW_Create${NAME} "${nsWindows}::CreateControl ${__NSW_${Name}_CLASS} ${__NSW_${Name}_STYLE} ${__NSW_${Name}_EXSTYLE}"
  298. !macroend
  299. !insertmacro __NSW_DefineControl HLine
  300. !insertmacro __NSW_DefineControl VLine
  301. !insertmacro __NSW_DefineControl Label
  302. !insertmacro __NSW_DefineControl Icon
  303. !insertmacro __NSW_DefineControl Bitmap
  304. !insertmacro __NSW_DefineControl BrowseButton
  305. !insertmacro __NSW_DefineControl Link
  306. !insertmacro __NSW_DefineControl Button
  307. !insertmacro __NSW_DefineControl GroupBox
  308. !insertmacro __NSW_DefineControl CheckBox
  309. !insertmacro __NSW_DefineControl RadioButton
  310. !insertmacro __NSW_DefineControl Text
  311. !insertmacro __NSW_DefineControl ReadText
  312. !insertmacro __NSW_DefineControl Memo
  313. !insertmacro __NSW_DefineControl Password
  314. !insertmacro __NSW_DefineControl Number
  315. !insertmacro __NSW_DefineControl FileRequest
  316. !insertmacro __NSW_DefineControl DirRequest
  317. !insertmacro __NSW_DefineControl ComboBox
  318. !insertmacro __NSW_DefineControl DropList
  319. !insertmacro __NSW_DefineControl ListBox
  320. !insertmacro __NSW_DefineControl ProgressBar
  321. !macro __NSW_OnControlEvent EVENT HWND FUNCTION
  322. Push $0
  323. Push $1
  324. StrCpy $1 "${HWND}"
  325. GetFunctionAddress $0 "${FUNCTION}"
  326. ${nsWindows}::On${EVENT} $1 $0
  327. Pop $1
  328. Pop $0
  329. !macroend
  330. !macro __NSW_DefineControlCallback EVENT
  331. !define NSW_On${EVENT} `!insertmacro __NSW_OnControlEvent ${EVENT}`
  332. !macroend
  333. !macro __NSW_OnDialogEvent EVENT FUNCTION
  334. Push $0
  335. GetFunctionAddress $0 "${FUNCTION}"
  336. ${nsWindows}::On${EVENT} $0
  337. Pop $0
  338. !macroend
  339. !macro __NSW_DefineDialogCallback EVENT
  340. !define NSW_On${EVENT} `!insertmacro __NSW_OnDialogEvent ${EVENT}`
  341. !macroend
  342. !insertmacro __NSW_DefineControlCallback Click
  343. !insertmacro __NSW_DefineControlCallback Change
  344. !insertmacro __NSW_DefineControlCallback Notify
  345. !insertmacro __NSW_DefineControlCallback DropFiles
  346. !insertmacro __NSW_DefineDialogCallback Back
  347. !macro _NSW_CreateTimer FUNCTION INTERVAL
  348. Push $0
  349. GetFunctionAddress $0 "${FUNCTION}"
  350. ${nsWindows}::CreateTimer $0 "${INTERVAL}"
  351. Pop $0
  352. !macroend
  353. !define NSW_CreateTimer `!insertmacro _NSW_CreateTimer`
  354. !macro _NSW_KillTimer FUNCTION
  355. Push $0
  356. GetFunctionAddress $0 "${FUNCTION}"
  357. ${nsWindows}::KillTimer $0
  358. Pop $0
  359. !macroend
  360. !define NSW_KillTimer `!insertmacro _NSW_KillTimer`
  361. !macro _NSW_AddStyle CONTROL STYLE
  362. Push $0
  363. System::Call "user32::GetWindowLong(i ${CONTROL}, i ${GWL_STYLE}) i .r0"
  364. System::Call "user32::SetWindowLong(i ${CONTROL}, i ${GWL_STYLE}, i $0|${STYLE})"
  365. Pop $0
  366. !macroend
  367. !define NSW_AddStyle "!insertmacro _NSW_AddStyle"
  368. !macro _NSW_AddExStyle CONTROL EXSTYLE
  369. Push $0
  370. System::Call "user32::GetWindowLong(i ${CONTROL}, i ${GWL_EXSTYLE}) i .r0"
  371. System::Call "user32::SetWindowLong(i ${CONTROL}, i ${GWL_EXSTYLE}, i $0|${EXSTYLE})"
  372. Pop $0
  373. !macroend
  374. !define NSW_AddExStyle "!insertmacro _NSW_AddExStyle"
  375. !macro __NSW_GetText CONTROL VAR
  376. System::Call user32::GetWindowText(i${CONTROL},t.s,i${NSIS_MAX_STRLEN})
  377. Pop ${VAR}
  378. !macroend
  379. !define NSW_GetText `!insertmacro __NSW_GetText`
  380. !macro __NSW_SetWindowSize CONTROL Width Height
  381. System::Call user32::SetWindowPos(i${CONTROL},i0,i0,i0,i${Width},i${Height},i${SWP_NOMOVE})
  382. !macroend
  383. !define NSW_SetWindowSize `!insertmacro __NSW_SetWindowSize`
  384. !macro __NSW_SetWindowPos CONTROL Left Top
  385. System::Call user32::SetWindowPos(i${CONTROL},i0,i${Left},i${Top},i0,i0,i${SWP_NOSIZE})
  386. !macroend
  387. !define NSW_SetWindowPos `!insertmacro __NSW_SetWindowPos`
  388. !macro __NSW_SetWindowPosEx CONTROL hWndInsertAfter Left Top Width Height uFlags
  389. System::Call user32::SetWindowPos(i${CONTROL},i${hWndInsertAfter},i${Left},i${Top},i${Width},i${Height},i${uFlags})
  390. !macroend
  391. !define NSW_SetWindowPosEx `!insertmacro __NSW_SetWindowPosEx`
  392. !macro _NSW_SetTransparent CONTROL PERCENT
  393. ${nsWindows}::SetTransparent ${CONTROL} ${PERCENT}
  394. !macroend
  395. !define NSW_SetTransparent `!insertmacro _NSW_SetTransparent`
  396. !macro __NSW_SetParent CONTROL PARENT
  397. System::Call user32::SetParent(i${CONTROL},i${PARENT})
  398. !macroend
  399. !define NSW_SetParent `!insertmacro __NSW_SetParent`
  400. !macro __NSW_DestroyWindow CONTROL
  401. System::Call user32::DestroyWindow(i${CONTROL})
  402. !macroend
  403. !define NSW_DestroyWindow `!insertmacro __NSW_DestroyWindow`
  404. !define NSW_CloseWindow `!insertmacro __NSW_DestroyWindow`
  405. !macro __NSW_MinimizeWindow CONTROL
  406. ShowWindow ${CONTROL} ${SW_MINIMIZE}
  407. ; System::Call user32::CloseWindow(i${CONTROL})
  408. !macroend
  409. !define NSW_MinimizeWindow `!insertmacro __NSW_MinimizeWindow`
  410. !macro __NSW_MaximizeWindow CONTROL
  411. ShowWindow ${CONTROL} ${SW_MAXIMIZE}
  412. !macroend
  413. !define NSW_MaximizeWindow `!insertmacro __NSW_MaximizeWindow`
  414. !macro __NSW_RestoreWindow CONTROL
  415. ShowWindow ${CONTROL} ${SW_NORMAL}
  416. ; System::Call user32::OpenIcon(i${CONTROL})
  417. !macroend
  418. !define NSW_RestoreWindow `!insertmacro __NSW_RestoreWindow`
  419. !macro __NSW_SetCtlText HWND FileName
  420. /*;用法:
  421. ;${NSW_SetCtlText} 控件句柄 文本文件名称
  422. ;此宏改自Restools的SetText函数
  423. ;链接:http://restools.hanzify.org/article.asp?id=29*/
  424. # 如果你对程序设计不熟悉,那么你可以不用理解这个过程,把它复制到你的脚本中就可以了。
  425. ; Exch $R0 ;${HWND}控件句柄
  426. ; Exch
  427. ; Exch $R1 ;${FileName}文件
  428. StrCpy $R0 ${HWND}
  429. StrCpy $R1 "${FileName}"
  430. Push $R2
  431. Push $R3
  432. Push $R4
  433. Push $R5
  434. ClearErrors
  435. FileOpen $R2 $R1 r ;$R2 = 文件句柄
  436. ${Unless} ${Errors} ;确保打开文件没有发生错误
  437. System::Call /NOUNLOAD "Kernel32::GetFileSize(i, i) i (R2, 0) .R3" ;$R3 = 文件大小
  438. IntOp $R3 $R3 + 1
  439. System::Alloc /NOUNLOAD $R3 ;分配内存
  440. Pop $R4 ;内存地址
  441. ${If} $R4 U> 0 ;确保分配了内存
  442. System::Call /NOUNLOAD "*(i 0) i .R5"
  443. System::Call /NOUNLOAD `Kernel32::ReadFile(i, i, i, i, i) i (R2, R4R4, R3, R5R5, 0)`
  444. System::Call /NOUNLOAD "*$R5(i .R1)"
  445. ${If} $R1 > 0
  446. System::Call /NOUNLOAD "User32::SendMessage(i, i, i, i) i (R0, ${WM_SETTEXT}, 0, R4)"
  447. ${EndIf}
  448. System::Free /NOUNLOAD $R5
  449. System::Free $R4 ;释放内存
  450. ${EndIf}
  451. FileClose $R2
  452. ${EndUnless}
  453. Pop $R5
  454. Pop $R4
  455. Pop $R3
  456. Pop $R2
  457. Pop $R1
  458. Pop $R0
  459. !macroend
  460. !define NSW_SetCtlText `!insertmacro __NSW_SetCtlText`
  461. !macro __NSW_SetText CONTROL TEXT
  462. SendMessage ${CONTROL} ${WM_SETTEXT} 0 `STR:${TEXT}`
  463. !macroend
  464. !define NSW_SetText `!insertmacro __NSW_SetText`
  465. !macro _NSW_SetTextLimit CONTROL LIMIT
  466. SendMessage ${CONTROL} ${EM_SETLIMITTEXT} ${LIMIT} 0
  467. !macroend
  468. !define NSW_SetTextLimit "!insertmacro _NSW_SetTextLimit"
  469. !macro __NSW_GetState CONTROL VAR
  470. SendMessage ${CONTROL} ${BM_GETCHECK} 0 0 ${VAR}
  471. !macroend
  472. !define NSW_GetState `!insertmacro __NSW_GetState`
  473. !macro __NSW_SetState CONTROL STATE
  474. SendMessage ${CONTROL} ${BM_SETCHECK} ${STATE} 0
  475. !macroend
  476. !define NSW_SetState `!insertmacro __NSW_SetState`
  477. !macro __NSW_Check CONTROL
  478. ${NSW_SetState} ${CONTROL} ${BST_CHECKED}
  479. !macroend
  480. !define NSW_Check `!insertmacro __NSW_Check`
  481. !macro __NSW_Uncheck CONTROL
  482. ${NSW_SetState} ${CONTROL} ${BST_UNCHECKED}
  483. !macroend
  484. !define NSW_Uncheck `!insertmacro __NSW_Uncheck`
  485. !macro __NSW_SetFocus HWND
  486. System::Call "user32::SetFocus(i${HWND})"
  487. !macroend
  488. !define NSW_SetFocus `!insertmacro __NSW_SetFocus`
  489. !macro _NSW_CB_AddString CONTROL STRING
  490. SendMessage ${CONTROL} ${CB_ADDSTRING} 0 `STR:${STRING}`
  491. !macroend
  492. !define NSW_CB_AddString "!insertmacro _NSW_CB_AddString"
  493. !macro _NSW_CB_SelectString CONTROL STRING
  494. SendMessage ${CONTROL} ${CB_SELECTSTRING} -1 `STR:${STRING}`
  495. !macroend
  496. !define NSW_CB_SelectString "!insertmacro _NSW_CB_SelectString"
  497. !macro __NSW_CB_GetSelection CONTROL VAR
  498. SendMessage ${CONTROL} ${CB_GETCURSEL} 0 0 ${VAR}
  499. System::Call 'user32::SendMessage(i ${CONTROL}, i ${CB_GETLBTEXT}, i ${VAR}, t .s)'
  500. Pop ${VAR}
  501. !macroend
  502. !define NSW_CB_GetSelection `!insertmacro __NSW_CB_GetSelection`
  503. !macro __NSW_CB_GetCurIndex CONTROL VAR
  504. SendMessage ${CONTROL} ${CB_GETCURSEL} 0 0 ${VAR}
  505. !macroend
  506. !define NSW_CB_GetCurIndex `!insertmacro __NSW_CB_GetCurIndex`
  507. !macro __NSW_CB_SetCurIndex CONTROL INDEX
  508. SendMessage ${CONTROL} ${CB_SETCURSEL} ${INDEX} 0
  509. !macroend
  510. !define NSW_CB_SetCurIndex `!insertmacro __NSW_CB_SetCurIndex`
  511. !macro _NSW_LB_AddString CONTROL STRING
  512. SendMessage ${CONTROL} ${LB_ADDSTRING} 0 `STR:${STRING}`
  513. !macroend
  514. !define NSW_LB_AddString "!insertmacro _NSW_LB_AddString"
  515. !macro __NSW_LB_DelString CONTROL STRING
  516. SendMessage ${CONTROL} ${LB_DELETESTRING} 0 `STR:${STRING}`
  517. !macroend
  518. !define NSW_LB_DelString `!insertmacro __NSW_LB_DelString`
  519. !macro __NSW_LB_Clear CONTROL VAR
  520. SendMessage ${CONTROL} ${LB_RESETCONTENT} 0 0 ${VAR}
  521. !macroend
  522. !define NSW_LB_Clear `!insertmacro __NSW_LB_Clear`
  523. !macro __NSW_LB_GetCount CONTROL VAR
  524. SendMessage ${CONTROL} ${LB_GETCOUNT} 0 0 ${VAR}
  525. !macroend
  526. !define NSW_LB_GetCount `!insertmacro __NSW_LB_GetCount`
  527. !macro _NSW_LB_SelectString CONTROL STRING
  528. SendMessage ${CONTROL} ${LB_SELECTSTRING} -1 `STR:${STRING}`
  529. !macroend
  530. !define NSW_LB_SelectString "!insertmacro _NSW_LB_SelectString"
  531. !macro __NSW_LB_GetSelection CONTROL VAR
  532. SendMessage ${CONTROL} ${LB_GETCURSEL} 0 0 ${VAR}
  533. System::Call 'user32::SendMessage(i ${CONTROL}, i ${LB_GETTEXT}, i ${VAR}, t .s)'
  534. Pop ${VAR}
  535. !macroend
  536. !define NSW_LB_GetSelection `!insertmacro __NSW_LB_GetSelection`
  537. !macro __NSW_LoadAndSetImage _LIHINSTMODE _IMGTYPE _LIHINSTSRC _LIFLAGS CONTROL IMAGE HANDLE
  538. Push $0
  539. Push $R0
  540. StrCpy $R0 ${CONTROL} # in case ${CONTROL} is $0
  541. !if "${_LIHINSTMODE}" == "exeresource"
  542. System::Call 'kernel32::GetModuleHandle(i0) i.r0'
  543. !undef _LIHINSTSRC
  544. !define _LIHINSTSRC r0
  545. !endif
  546. System::Call 'user32::LoadImage(i ${_LIHINSTSRC}, ts, i ${_IMGTYPE}, i0, i0, i${_LIFLAGS}) i.r0' "${IMAGE}"
  547. SendMessage $R0 ${STM_SETIMAGE} ${_IMGTYPE} $0
  548. Pop $R0
  549. Exch $0
  550. Pop ${HANDLE}
  551. !macroend
  552. !macro __NSW_SetIconFromExeResource CONTROL IMAGE HANDLE
  553. !insertmacro __NSW_LoadAndSetImage exeresource ${IMAGE_ICON} 0 ${LR_DEFAULTSIZE} "${CONTROL}" "${IMAGE}" ${HANDLE}
  554. !macroend
  555. !macro __NSW_SetIconFromInstaller CONTROL HANDLE
  556. !insertmacro __NSW_SetIconFromExeResource "${CONTROL}" "#103" ${HANDLE}
  557. !macroend
  558. !define NSW_SetImage `!insertmacro __NSW_LoadAndSetImage file ${IMAGE_BITMAP} 0 "${LR_LOADFROMFILE}"`
  559. !define NSW_SetBitmap `${NSW_SetImage}`
  560. !define NSW_SetIcon `!insertmacro __NSW_LoadAndSetImage file ${IMAGE_ICON} 0 "${LR_LOADFROMFILE}|${LR_DEFAULTSIZE}"`
  561. !define NSW_SetIconFromExeResource `!insertmacro __NSW_SetIconFromExeResource`
  562. !define NSW_SetIconFromInstaller `!insertmacro __NSW_SetIconFromInstaller`
  563. !macro __NSW_SetStretchedImage CONTROL IMAGE HANDLE
  564. Push $0
  565. Push $1
  566. Push $2
  567. Push $R0
  568. StrCpy $R0 ${CONTROL} # in case ${CONTROL} is $0
  569. StrCpy $1 ""
  570. StrCpy $2 ""
  571. System::Call '*(i, i, i, i) i.s'
  572. Pop $0
  573. ${If} $0 <> 0
  574. System::Call 'user32::GetClientRect(iR0, ir0)'
  575. System::Call '*$0(i, i, i .s, i .s)'
  576. System::Free $0
  577. Pop $1
  578. Pop $2
  579. ${EndIf}
  580. System::Call 'user32::LoadImage(i0, ts, i ${IMAGE_BITMAP}, ir1, ir2, i${LR_LOADFROMFILE}) i.s' "${IMAGE}"
  581. Pop $0
  582. SendMessage $R0 ${STM_SETIMAGE} ${IMAGE_BITMAP} $0
  583. Pop $R0
  584. Pop $2
  585. Pop $1
  586. Exch $0
  587. Pop ${HANDLE}
  588. !macroend
  589. !define NSW_SetStretchedImage `!insertmacro __NSW_SetStretchedImage`
  590. !macro __NSW_FreeImage IMAGE
  591. ${If} ${IMAGE} <> 0
  592. System::Call gdi32::DeleteObject(is) ${IMAGE}
  593. ${EndIf}
  594. !macroend
  595. !define NSW_FreeImage `!insertmacro __NSW_FreeImage`
  596. !define NSW_FreeBitmap `${NSW_FreeImage}`
  597. !macro __NSW_FreeIcon IMAGE
  598. System::Call user32::DestroyIcon(is) ${IMAGE}
  599. !macroend
  600. !define NSW_FreeIcon `!insertmacro __NSW_FreeIcon`
  601. !macro __NSW_ClearImage _IMGTYPE CONTROL
  602. SendMessage ${CONTROL} ${STM_SETIMAGE} ${_IMGTYPE} 0
  603. !macroend
  604. !define NSW_ClearImage `!insertmacro __NSW_ClearImage ${IMAGE_BITMAP}`
  605. !define NSW_ClearIcon `!insertmacro __NSW_ClearImage ${IMAGE_ICON}`
  606. !ifndef DEBUG
  607. !define DEBUG `System::Call kernel32::OutputDebugString(ts)`
  608. !endif
  609. !macro __NSW_ControlCase TYPE
  610. ${Case} ${TYPE}
  611. ${NSW_Create${TYPE}} $R3u $R4u $R5u $R6u $R7
  612. Pop $R9
  613. ${Break}
  614. !macroend
  615. !macro __NSW_ControlCaseEx TYPE
  616. ${Case} ${TYPE}
  617. Call ${TYPE}
  618. ${Break}
  619. !macroend
  620. !macro NSW_FUNCTION_INIFILE
  621. !insertmacro NSW_INIFILE ""
  622. !macroend
  623. !macro NSW_UNFUNCTION_INIFILE
  624. !insertmacro NSW_INIFILE un.
  625. !macroend
  626. !macro NSW_INIFILE UNINSTALLER_FUNCPREFIX
  627. ;Functions to create dialogs based on old InstallOptions INI files
  628. Function ${UNINSTALLER_FUNCPREFIX}CreateDialogFromINI
  629. ;Window name
  630. Pop $R1
  631. # $0 = ini
  632. ReadINIStr $R0 $0 Settings RECT
  633. ${If} $R0 == ""
  634. StrCpy $R0 1018
  635. ${EndIf}
  636. Pop $R9
  637. ${NSW_CreateWindow} $R9 $R1 $R0
  638. ; ${nsWindows}::Create $hwndparent ${dwExStyle} ${dwStyle} $R1 $R0
  639. ; ${nsWindows}::Create $hwndparent ${dwExStyle} ${dwStyle} $R1 $R0
  640. ; ${nsWindows}::Create $R0
  641. ReadINIStr $R0 $0 Settings RTL
  642. ${nsWindows}::SetRTL $R0
  643. ReadINIStr $R0 $0 Settings NumFields
  644. ${DEBUG} "NumFields = $R0"
  645. ${For} $R1 1 $R0
  646. ${DEBUG} "Creating field $R1"
  647. ReadINIStr $R2 $0 "Field $R1" Type
  648. ${DEBUG} " Type = $R2"
  649. ReadINIStr $R3 $0 "Field $R1" Left
  650. ${DEBUG} " Left = $R3"
  651. ReadINIStr $R4 $0 "Field $R1" Top
  652. ${DEBUG} " Top = $R4"
  653. ReadINIStr $R5 $0 "Field $R1" Right
  654. ${DEBUG} " Right = $R5"
  655. ReadINIStr $R6 $0 "Field $R1" Bottom
  656. ${DEBUG} " Bottom = $R6"
  657. IntOp $R5 $R5 - $R3
  658. ${DEBUG} " Width = $R5"
  659. IntOp $R6 $R6 - $R4
  660. ${DEBUG} " Height = $R6"
  661. ReadINIStr $R7 $0 "Field $R1" Text
  662. ${DEBUG} " Text = $R7"
  663. ${Switch} $R2
  664. !insertmacro __NSW_ControlCase HLine
  665. !insertmacro __NSW_ControlCase VLine
  666. !insertmacro __NSW_ControlCase Label
  667. !insertmacro __NSW_ControlCase Icon
  668. !insertmacro __NSW_ControlCase Bitmap
  669. !insertmacro __NSW_ControlCaseEx Link
  670. !insertmacro __NSW_ControlCase Button
  671. !insertmacro __NSW_ControlCase GroupBox
  672. !insertmacro __NSW_ControlCase CheckBox
  673. !insertmacro __NSW_ControlCase RadioButton
  674. !insertmacro __NSW_ControlCase Text
  675. !insertmacro __NSW_ControlCase Password
  676. !insertmacro __NSW_ControlCaseEx FileRequest
  677. !insertmacro __NSW_ControlCaseEx DirRequest
  678. !insertmacro __NSW_ControlCase ComboBox
  679. !insertmacro __NSW_ControlCase DropList
  680. !insertmacro __NSW_ControlCase ListBox
  681. ${EndSwitch}
  682. WriteINIStr $0 "Field $R1" HWND $R9
  683. ${Next}
  684. ; nsWindows::Show
  685. ${NSW_Show}
  686. FunctionEnd
  687. Function ${UNINSTALLER_FUNCPREFIX}UpdateINIState
  688. ${DEBUG} "Updating INI state"
  689. ReadINIStr $R0 $0 Settings NumFields
  690. ${DEBUG} "NumField = $R0"
  691. ${For} $R1 1 $R0
  692. ReadINIStr $R2 $0 "Field $R1" HWND
  693. ReadINIStr $R3 $0 "Field $R1" "Type"
  694. ${Switch} $R3
  695. ${Case} "CheckBox"
  696. ${Case} "RadioButton"
  697. ${DEBUG} " HWND = $R2"
  698. ${NSW_GetState} $R2 $R2
  699. ${DEBUG} " Window selection = $R2"
  700. ${Break}
  701. ${CaseElse}
  702. ${DEBUG} " HWND = $R2"
  703. ${NSW_GetText} $R2 $R2
  704. ${DEBUG} " Window text = $R2"
  705. ${Break}
  706. ${EndSwitch}
  707. WriteINIStr $0 "Field $R1" STATE $R2
  708. ${Next}
  709. FunctionEnd
  710. Function ${UNINSTALLER_FUNCPREFIX}FileRequest
  711. IntOp $R5 $R5 - 15
  712. IntOp $R8 $R3 + $R5
  713. ${NSW_CreateBrowseButton} $R8u $R4u 15u $R6u ...
  714. Pop $R8
  715. ${nsWindows}::SetUserData $R8 $R1 # remember field id
  716. WriteINIStr $0 "Field $R1" HWND2 $R8
  717. ${NSW_OnClick} $R8 ${UNINSTALLER_FUNCPREFIX}OnFileBrowseButton
  718. ReadINIStr $R9 $0 "Field $R1" State
  719. ${NSW_CreateFileRequest} $R3u $R4u $R5u $R6u $R9
  720. Pop $R9
  721. FunctionEnd
  722. Function ${UNINSTALLER_FUNCPREFIX}DirRequest
  723. IntOp $R5 $R5 - 15
  724. IntOp $R8 $R3 + $R5
  725. ${NSW_CreateBrowseButton} $R8u $R4u 15u $R6u ...
  726. Pop $R8
  727. ${nsWindows}::SetUserData $R8 $R1 # remember field id
  728. WriteINIStr $0 "Field $R1" HWND2 $R8
  729. ${NSW_OnClick} $R8 ${UNINSTALLER_FUNCPREFIX}OnDirBrowseButton
  730. ReadINIStr $R9 $0 "Field $R1" State
  731. ${NSW_CreateFileRequest} $R3u $R4u $R5u $R6u $R9
  732. Pop $R9
  733. FunctionEnd
  734. Function ${UNINSTALLER_FUNCPREFIX}OnFileBrowseButton
  735. Pop $R0
  736. ${nsWindows}::GetUserData $R0
  737. Pop $R1
  738. ReadINIStr $R2 $0 "Field $R1" HWND
  739. ReadINIStr $R4 $0 "Field $R1" Filter
  740. ${NSW_GetText} $R2 $R3
  741. ${nsWindows}::SelectFileDialog save $R3 $R4
  742. Pop $R3
  743. ${If} $R3 != ""
  744. SendMessage $R2 ${WM_SETTEXT} 0 STR:$R3
  745. ${EndIf}
  746. FunctionEnd
  747. Function ${UNINSTALLER_FUNCPREFIX}OnDirBrowseButton
  748. Pop $R0
  749. ${nsWindows}::GetUserData $R0
  750. Pop $R1
  751. ReadINIStr $R2 $0 "Field $R1" HWND
  752. ReadINIStr $R3 $0 "Field $R1" Text
  753. ${NSW_GetText} $R2 $R4
  754. ${nsWindows}::SelectFolderDialog $R3 $R4
  755. Pop $R3
  756. ${If} $R3 != error
  757. SendMessage $R2 ${WM_SETTEXT} 0 STR:$R3
  758. ${EndIf}
  759. FunctionEnd
  760. Function ${UNINSTALLER_FUNCPREFIX}Link
  761. ${NSW_CreateLink} $R3u $R4u $R5u $R6u $R7
  762. Pop $R9
  763. ${nsWindows}::SetUserData $R9 $R1 # remember field id
  764. ${NSW_OnClick} $R9 ${UNINSTALLER_FUNCPREFIX}OnLink
  765. FunctionEnd
  766. Function ${UNINSTALLER_FUNCPREFIX}OnLink
  767. Pop $R0
  768. ${nsWindows}::GetUserData $R0
  769. Pop $R1
  770. ReadINIStr $R1 $0 "Field $R1" STATE
  771. ExecShell "" $R1
  772. FunctionEnd
  773. !macroend
  774. !verbose pop
  775. !endif