windowRect.nsh 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  1. !ifndef NULLSOFT_NX_WINDOW_RECT_NSIS_HEADER
  2. !define NULLSOFT_NX_WINDOW_RECT_NSIS_HEADER
  3. !include "util.nsh"
  4. !include "logicLib.nsh"
  5. !include "system.nsh"
  6. !macro NX_GetWindowRectInternal
  7. Exch $0
  8. Push $2
  9. Push $3
  10. Push $4
  11. Push $5
  12. Push $1
  13. System::Call "*${stRECT} .r1"
  14. System::Call "${fnGetWindowRect}($0, $1)"
  15. System::Call "*$1${stRECT} (.r2, .r3, .r4, .r5)"
  16. System::Free $1
  17. Pop $1
  18. Exch 4
  19. Pop $0
  20. Exch $5
  21. Exch 3
  22. Exch $2
  23. Exch
  24. Exch $4
  25. Exch 2
  26. Exch $3
  27. Exch
  28. !macroend
  29. !macro NX_GetWindowRect __hwnd __left __top __right __bottom
  30. Push "${__hwnd}"
  31. ${CallArtificialFunction} NX_GetWindowRectInternal
  32. Pop "${__left}"
  33. Pop "${__top}"
  34. Pop "${__right}"
  35. Pop "${__bottom}"
  36. !macroend
  37. !define NX_GetWindowRect `!insertmacro NX_GetWindowRect`
  38. !macro NX_GetMappedWindowRectInternal
  39. Exch $0
  40. Exch
  41. Exch $2
  42. Push $3
  43. Push $4
  44. Push $5
  45. Push $1
  46. System::Call "*${stRECT} .r1"
  47. System::Call "${fnGetWindowRect}(r0, r1)"
  48. System::Call '${fnMapWindowPoints}(0, r2, r1, 2)'
  49. System::Call "*$1${stRECT} (.r5, .r2, .r3, .r4)"
  50. System::Free $1
  51. Pop $1
  52. Exch 4
  53. Pop $0
  54. Exch $4
  55. Exch 3
  56. Exch $5
  57. Exch
  58. Exch $3
  59. Exch 2
  60. Exch $2
  61. Exch
  62. !macroend
  63. !macro NX_GetMappedWindowRect __hwnd __hwndParent __left __top __right __bottom
  64. Push "${__hwndParent}"
  65. Push "${__hwnd}"
  66. ${CallArtificialFunction} NX_GetMappedWindowRectInternal
  67. Pop "${__left}"
  68. Pop "${__top}"
  69. Pop "${__right}"
  70. Pop "${__bottom}"
  71. !macroend
  72. !define NX_GetMappedWindowRect `!insertmacro NX_GetMappedWindowRect`
  73. !macro NX_GetWindowSizeInternal
  74. Exch $0
  75. Push $2
  76. Push $3
  77. Push $4
  78. Push $5
  79. Push $1
  80. System::Call "*${stRECT} .r1"
  81. System::Call "${fnGetWindowRect} ($0, $1)"
  82. System::Call "*$1${stRECT} (.r2, .r3, .r4, .r5)"
  83. System::Free $1
  84. Pop $1
  85. IntOp $0 $4 - $2
  86. IntOp $2 $5 - $3
  87. Pop $5
  88. Pop $4
  89. Pop $3
  90. Exch $2
  91. Exch
  92. Exch $0
  93. !macroend
  94. !macro NX_GetWindowSize __hwnd __width __height
  95. Push "${__hwnd}"
  96. ${CallArtificialFunction} NX_GetWindowSizeInternal
  97. Pop "${__width}"
  98. Pop "${__height}"
  99. !macroend
  100. !define NX_GetWindowSize `!insertmacro NX_GetWindowSize`
  101. !macro NX_GetWindowPosInternal
  102. Exch $0
  103. Push $2
  104. Push $3
  105. Push $4
  106. Push $5
  107. Push $1
  108. System::Call "*${stRECT} .r1"
  109. System::Call "${fnGetWindowRect}($0, $1)"
  110. System::Call "*$1${stRECT} (.r2, .r3, .r4, .r5)"
  111. System::Free $1
  112. Pop $1
  113. StrCpy $0 $3
  114. Pop $5
  115. Pop $4
  116. Pop $3
  117. Exch $2
  118. Exch
  119. Exch $0
  120. Exch
  121. !macroend
  122. !macro NX_GetWindowPos __hwnd __left __top
  123. Push "${__hwnd}"
  124. ${CallArtificialFunction} NX_GetWindowPosInternal
  125. Pop "${__left}"
  126. Pop "${__top}"
  127. !macroend
  128. !define NX_GetWindowPos `!insertmacro NX_GetWindowPos`
  129. !macro NX_GetMappedWindowPosInternal
  130. Exch $0
  131. Exch
  132. Exch $2
  133. Push $3
  134. Push $4
  135. Push $5
  136. Push $1
  137. System::Call "*${stRECT} .r1"
  138. System::Call "${fnGetWindowRect}($0, $1)"
  139. System::Call "${fnMapWindowPoints}(0, $2, r1, 1)"
  140. System::Call "*$1${stRECT} (.r2, .r3, .r4, .r5)"
  141. System::Free $1
  142. Pop $1
  143. StrCpy $0 $3
  144. Pop $5
  145. Pop $4
  146. Pop $3
  147. Exch $2
  148. Exch
  149. Exch $0
  150. Exch
  151. !macroend
  152. !macro NX_GetMappedWindowPos __hwnd __hwndParent __left __top
  153. Push "${__hwndParent}"
  154. Push "${__hwnd}"
  155. ${CallArtificialFunction} NX_GetMappedWindowPosInternal
  156. Pop "${__left}"
  157. Pop "${__top}"
  158. !macroend
  159. !define NX_GetMappedWindowPos `!insertmacro NX_GetMappedWindowPos`
  160. !macro NX_SetWindowPos __hwnd __left __top
  161. System::Call "${fnSetWindowPos} \
  162. (${__hwnd}, 0, ${__left}, ${__top}, 0, 0, \
  163. ${SWP_NOACTIVATE}|${SWP_NOZORDER}|${SWP_NOSIZE})"
  164. !macroend
  165. !define NX_SetWindowPos `!insertmacro NX_SetWindowPos`
  166. !macro NX_SetWindowSize __hwnd __width __height
  167. System::Call "${fnSetWindowPos} \
  168. (${__hwnd}, 0, 0, 0, ${__width}, ${__height}, \
  169. ${SWP_NOACTIVATE}|${SWP_NOZORDER}|${SWP_NOMOVE})"
  170. !macroend
  171. !define NX_SetWindowSize `!insertmacro NX_SetWindowSize`
  172. !macro NX_SetWindowPosAndSize __hwnd __left __top __width __height
  173. System::Call "User32::SetWindowPos(i, i, i, i, i, i, i) b \
  174. (${__hwnd}, 0, ${__left}, ${__top}, ${__width}, ${__height},\
  175. ${SWP_NOACTIVATE}|${SWP_NOZORDER})"
  176. !macroend
  177. !define NX_SetWindowPosAndSize `!insertmacro NX_SetWindowPosAndSize`
  178. !macro NX_SetWindowOrder __hwnd __insertAfterWindow
  179. System::Call "${fnSetWindowPos} \
  180. (${__hwnd}, ${__insertAfterWindow}, 0, 0, 0, 0, \
  181. ${SWP_NOACTIVATE}|${SWP_NOSIZE}|${SWP_NOMOVE})"
  182. !macroend
  183. !define NX_SetWindowOrder `!insertmacro NX_SetWindowOrder`
  184. !macro NX_OffsetWindowPosInternal
  185. !define hwnd_ $R0
  186. !define offsetX_ $R1
  187. !define offsetY_ $R2
  188. Exch ${offsetY_}
  189. Exch
  190. Exch ${offsetX_}
  191. Exch 2
  192. Exch ${hwnd_}
  193. Push $0
  194. Push $1
  195. Push $2
  196. Push $3
  197. Push $4
  198. System::Call "*${stRECT} .r4"
  199. System::Call "${fnGetWindowRect} (${hwnd_}, r4)"
  200. System::Call "${fnGetAncestor} (${hwnd_}, ${GA_PARENT}).r0"
  201. ${If} $R0 != 0
  202. System::Call "${fnMapWindowPoints} (0, r0, r4, 2)"
  203. ${EndIf}
  204. System::Call "*$4${stRECT} (.r0, .r1, .r2, .r3)"
  205. System::Free $4
  206. IntOp $0 $0 + ${offsetX_}
  207. IntOp $1 $1 + ${offsetY_}
  208. System::Call "${fnSetWindowPos} \
  209. (${hwnd_}, 0, $0, $1, 0, 0, \
  210. ${SWP_NOACTIVATE}|${SWP_NOZORDER}|${SWP_NOSIZE})"
  211. Pop $4
  212. Pop $3
  213. Pop $2
  214. Pop $1
  215. Pop $0
  216. Pop ${hwnd_}
  217. Pop ${offsetY_}
  218. Pop ${offsetX_}
  219. !undef hwnd_
  220. !undef offsetX_
  221. !undef offsetY_
  222. !macroend
  223. !macro NX_OffsetWindowPos __hwnd __offset_x __offset_y
  224. Push "${__hwnd}"
  225. Push "${__offset_x}"
  226. Push "${__offset_y}"
  227. ${CallArtificialFunction} NX_OffsetWindowPosInternal
  228. !macroend
  229. !define NX_OffsetWindowPos "!insertmacro 'NX_OffsetWindowPos'"
  230. !macro NX_IncreaseWindowSizeInternal
  231. !define hwnd_ $R0
  232. !define deltaCX_ $R1
  233. !define deltaCY_ $R2
  234. Exch ${deltaCY_}
  235. Exch
  236. Exch ${deltaCX_}
  237. Exch 2
  238. Exch ${hwnd_}
  239. Push $0
  240. Push $1
  241. Push $2
  242. Push $3
  243. Push $4
  244. System::Call "*${stRECT} .r4"
  245. System::Call "${fnGetWindowRect}(${hwnd_}, r4)"
  246. System::Call "*$4${stRECT} (.r0, .r1, .r2, .r3)"
  247. System::Free $4
  248. IntOp $0 $2 - $0
  249. IntOp $1 $3 - $1
  250. IntOp $0 $0 + ${deltaCX_}
  251. IntOp $1 $1 + ${deltaCY_}
  252. System::Call "${fnSetWindowPos}\
  253. (${__hwnd}, 0, 0, 0, $0, $1, \
  254. ${SWP_NOACTIVATE}|${SWP_NOZORDER}|${SWP_NOMOVE})"
  255. Pop $4
  256. Pop $3
  257. Pop $2
  258. Pop $1
  259. Pop $0
  260. Pop ${hwnd_}
  261. Pop ${deltaCY_}
  262. Pop ${deltaCX_}
  263. !undef hwnd_
  264. !undef deltaCX_
  265. !undef deltaCY_
  266. !macroend
  267. !macro NX_IncreaseWindowSize __hwnd __delta_cx __delta_cy
  268. Push "${__hwnd}"
  269. Push "${__delta_cx}"
  270. Push "${__delta_cy}"
  271. ${CallArtificialFunction} NX_IncreaseWindowSizeInternal
  272. !macroend
  273. !define NX_IncreaseWindowSize "!insertmacro 'NX_IncreaseWindowSize'"
  274. !macro NX_ConvertHorzDLUInternal
  275. Exch $1 ; dlu
  276. Exch
  277. Exch $0 ; hwnd
  278. Push $2
  279. System::Call "*${stRECT}($1, 0, 0, 0) .r2"
  280. System::Call "${fnMapDialogRect}($0, $2).s"
  281. Pop $1
  282. ${If} $1 != 0
  283. System::Call "*$2${stRECT} (.r1, _)"
  284. ${EndIf}
  285. System::Free $2
  286. Pop $2
  287. Pop $0
  288. Exch $1
  289. !macroend
  290. !macro NX_ConvertHorzDLU __hwnd __dlu __px
  291. Push "${__hwnd}"
  292. Push "${__dlu}"
  293. ${CallArtificialFunction} NX_ConvertHorzDLUInternal
  294. Pop "${__px}"
  295. !macroend
  296. !define NX_ConvertHorzDLU `!insertmacro NX_ConvertHorzDLU`
  297. !macro NX_ConvertVertDLUInternal
  298. Exch $1 ; dlu
  299. Exch
  300. Exch $0 ; hwnd
  301. Push $2
  302. System::Call "*${stRECT}(0, $1, 0, 0) .r2"
  303. System::Call "${fnMapDialogRect}($0, $2).s"
  304. Pop $1
  305. ${If} $1 != 0
  306. System::Call "*$2${stRECT} (., .r1, _)"
  307. ${EndIf}
  308. System::Free $2
  309. Pop $2
  310. Pop $0
  311. Exch $1
  312. !macroend
  313. !macro NX_ConvertVertDLU __hwnd __dlu __px
  314. Push "${__hwnd}"
  315. Push "${__dlu}"
  316. ${CallArtificialFunction} NX_ConvertVertDLUInternal
  317. Pop "${__px}"
  318. !macroend
  319. !define NX_ConvertVertDLU `!insertmacro NX_ConvertVertDLU`
  320. !endif ; defined(NULLSOFT_NX_WINDOW_RECT_NSIS_HEADER)