GuiStatusBar.au3 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. #include-once
  2. #include "Memory.au3"
  3. #include "SendMessage.au3"
  4. #include "StatusBarConstants.au3"
  5. #include "UDFGlobalID.au3"
  6. #include "WinAPIConv.au3"
  7. #include "WinAPISysInternals.au3"
  8. ; #INDEX# =======================================================================================================================
  9. ; Title .........: StatusBar
  10. ; AutoIt Version : 3.3.14.5
  11. ; Language ......: English
  12. ; Description ...: Functions that assist with StatusBar control management.
  13. ; A status bar is a horizontal window at the bottom of a parent window in which an application can display
  14. ; various kinds of status information. The status bar can be divided into parts to display more than one type
  15. ; of information
  16. ; Author(s) .....: Paul Campbell (PaulIA)
  17. ; ===============================================================================================================================
  18. ; #VARIABLES# ===================================================================================================================
  19. Global $__g_hSBLastWnd
  20. ; ===============================================================================================================================
  21. ; #CONSTANTS# ===================================================================================================================
  22. Global Const $__STATUSBARCONSTANT_ClassName = "msctls_statusbar32"
  23. Global Const $__STATUSBARCONSTANT_WM_SIZE = 0x05
  24. Global Const $__STATUSBARCONSTANT_CLR_DEFAULT = 0xFF000000
  25. ; ===============================================================================================================================
  26. ; #CURRENT# =====================================================================================================================
  27. ; _GUICtrlStatusBar_Create
  28. ; _GUICtrlStatusBar_Destroy
  29. ; _GUICtrlStatusBar_EmbedControl
  30. ; _GUICtrlStatusBar_GetBorders
  31. ; _GUICtrlStatusBar_GetBordersHorz
  32. ; _GUICtrlStatusBar_GetBordersRect
  33. ; _GUICtrlStatusBar_GetBordersVert
  34. ; _GUICtrlStatusBar_GetCount
  35. ; _GUICtrlStatusBar_GetHeight
  36. ; _GUICtrlStatusBar_GetIcon
  37. ; _GUICtrlStatusBar_GetParts
  38. ; _GUICtrlStatusBar_GetRect
  39. ; _GUICtrlStatusBar_GetRectEx
  40. ; _GUICtrlStatusBar_GetText
  41. ; _GUICtrlStatusBar_GetTextFlags
  42. ; _GUICtrlStatusBar_GetTextLength
  43. ; _GUICtrlStatusBar_GetTextLengthEx
  44. ; _GUICtrlStatusBar_GetTipText
  45. ; _GUICtrlStatusBar_GetUnicodeFormat
  46. ; _GUICtrlStatusBar_GetWidth
  47. ; _GUICtrlStatusBar_IsSimple
  48. ; _GUICtrlStatusBar_Resize
  49. ; _GUICtrlStatusBar_SetBkColor
  50. ; _GUICtrlStatusBar_SetIcon
  51. ; _GUICtrlStatusBar_SetMinHeight
  52. ; _GUICtrlStatusBar_SetParts
  53. ; _GUICtrlStatusBar_SetSimple
  54. ; _GUICtrlStatusBar_SetText
  55. ; _GUICtrlStatusBar_SetTipText
  56. ; _GUICtrlStatusBar_SetUnicodeFormat
  57. ; _GUICtrlStatusBar_ShowHide
  58. ; ===============================================================================================================================
  59. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  60. ; $tagBORDERS
  61. ; ===============================================================================================================================
  62. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  63. ; Name...........: $tagBORDERS
  64. ; Description ...: Structure that recieves the current widths of the horizontal and vertical borders of a status window
  65. ; Fields ........: BX - Width of the horizontal border
  66. ; BY - Width of the vertical border
  67. ; RX - Width of the border between rectangles
  68. ; Author ........: Gary Frost (gafrost)
  69. ; Remarks .......:
  70. ; ===============================================================================================================================
  71. Global Const $tagBORDERS = "int BX;int BY;int RX"
  72. ; #FUNCTION# ====================================================================================================================
  73. ; Author ........: Gary Frost, Steve Podhajecki <gehossafats at netmdc dot com>
  74. ; Modified.......: Gary Frost
  75. ; ===============================================================================================================================
  76. Func _GUICtrlStatusBar_Create($hWnd, $vPartEdge = -1, $vPartText = "", $iStyles = -1, $iExStyles = 0x00000000)
  77. If Not IsHWnd($hWnd) Then Return SetError(1, 0, 0) ; Invalid Window handle for _GUICtrlStatusBar_Create 1st parameter
  78. Local $iStyle = BitOR($__UDFGUICONSTANT_WS_CHILD, $__UDFGUICONSTANT_WS_VISIBLE)
  79. If $iStyles = -1 Then $iStyles = 0x00000000
  80. If $iExStyles = -1 Then $iExStyles = 0x00000000
  81. Local $aPartWidth[1], $aPartText[1]
  82. If @NumParams > 1 Then ; more than param passed in
  83. ; setting up arrays
  84. If IsArray($vPartEdge) Then ; setup part width array
  85. $aPartWidth = $vPartEdge
  86. Else
  87. $aPartWidth[0] = $vPartEdge
  88. EndIf
  89. If @NumParams = 2 Then ; part text was not passed in so set array to same size as part width array
  90. ReDim $aPartText[UBound($aPartWidth)]
  91. Else
  92. If IsArray($vPartText) Then ; setup part text array
  93. $aPartText = $vPartText
  94. Else
  95. $aPartText[0] = $vPartText
  96. EndIf
  97. ; if partwidth array is not same size as parttext array use larger sized array for size
  98. If UBound($aPartWidth) <> UBound($aPartText) Then
  99. Local $iLast
  100. If UBound($aPartWidth) > UBound($aPartText) Then ; width array is larger
  101. $iLast = UBound($aPartText)
  102. ReDim $aPartText[UBound($aPartWidth)]
  103. Else ; text array is larger
  104. $iLast = UBound($aPartWidth)
  105. ReDim $aPartWidth[UBound($aPartText)]
  106. For $x = $iLast To UBound($aPartWidth) - 1
  107. $aPartWidth[$x] = $aPartWidth[$x - 1] + 75
  108. Next
  109. $aPartWidth[UBound($aPartText) - 1] = -1
  110. EndIf
  111. EndIf
  112. EndIf
  113. If Not IsHWnd($hWnd) Then $hWnd = HWnd($hWnd)
  114. If @NumParams > 3 Then $iStyle = BitOR($iStyle, $iStyles)
  115. EndIf
  116. Local $nCtrlID = __UDF_GetNextGlobalID($hWnd)
  117. If @error Then Return SetError(@error, @extended, 0)
  118. Local $hWndSBar = _WinAPI_CreateWindowEx($iExStyles, $__STATUSBARCONSTANT_ClassName, "", $iStyle, 0, 0, 0, 0, $hWnd, $nCtrlID)
  119. If @error Then Return SetError(@error, @extended, 0)
  120. If @NumParams > 1 Then ; set the parts/text
  121. _GUICtrlStatusBar_SetParts($hWndSBar, UBound($aPartWidth), $aPartWidth)
  122. For $x = 0 To UBound($aPartText) - 1
  123. _GUICtrlStatusBar_SetText($hWndSBar, $aPartText[$x], $x)
  124. Next
  125. EndIf
  126. Return $hWndSBar
  127. EndFunc ;==>_GUICtrlStatusBar_Create
  128. ; #FUNCTION# ====================================================================================================================
  129. ; Author ........: Gary Frost (gafrost)
  130. ; Modified.......:
  131. ; ===============================================================================================================================
  132. Func _GUICtrlStatusBar_Destroy(ByRef $hWnd)
  133. If Not _WinAPI_IsClassName($hWnd, $__STATUSBARCONSTANT_ClassName) Then Return SetError(2, 2, False)
  134. Local $iDestroyed = 0
  135. If IsHWnd($hWnd) Then
  136. If _WinAPI_InProcess($hWnd, $__g_hSBLastWnd) Then
  137. Local $nCtrlID = _WinAPI_GetDlgCtrlID($hWnd)
  138. Local $hParent = _WinAPI_GetParent($hWnd)
  139. $iDestroyed = _WinAPI_DestroyWindow($hWnd)
  140. Local $iRet = __UDF_FreeGlobalID($hParent, $nCtrlID)
  141. If Not $iRet Then
  142. ; can check for errors here if needed, for debug
  143. EndIf
  144. Else
  145. ; Not Allowed to Destroy Other Applications Control(s)
  146. Return SetError(1, 1, False)
  147. EndIf
  148. EndIf
  149. If $iDestroyed Then $hWnd = 0
  150. Return $iDestroyed <> 0
  151. EndFunc ;==>_GUICtrlStatusBar_Destroy
  152. ; #FUNCTION# ====================================================================================================================
  153. ; Author ........: Paul Campbell (PaulIA)
  154. ; Modified.......:
  155. ; ===============================================================================================================================
  156. Func _GUICtrlStatusBar_EmbedControl($hWnd, $iPart, $hControl, $iFit = 4)
  157. Local $aRect = _GUICtrlStatusBar_GetRect($hWnd, $iPart)
  158. Local $iBarX = $aRect[0]
  159. Local $iBarY = $aRect[1]
  160. Local $iBarW = $aRect[2] - $iBarX
  161. Local $iBarH = $aRect[3] - $iBarY
  162. Local $iConX = $iBarX
  163. Local $iConY = $iBarY
  164. Local $iConW = _WinAPI_GetWindowWidth($hControl)
  165. Local $iConH = _WinAPI_GetWindowHeight($hControl)
  166. If $iConW > $iBarW Then $iConW = $iBarW
  167. If $iConH > $iBarH Then $iConH = $iBarH
  168. Local $iPadX = ($iBarW - $iConW) / 2
  169. Local $iPadY = ($iBarH - $iConH) / 2
  170. If $iPadX < 0 Then $iPadX = 0
  171. If $iPadY < 0 Then $iPadY = 0
  172. If BitAND($iFit, 1) = 1 Then $iConX = $iBarX + $iPadX
  173. If BitAND($iFit, 2) = 2 Then $iConY = $iBarY + $iPadY
  174. If BitAND($iFit, 4) = 4 Then
  175. $iPadX = _GUICtrlStatusBar_GetBordersRect($hWnd)
  176. $iPadY = _GUICtrlStatusBar_GetBordersVert($hWnd)
  177. $iConX = $iBarX
  178. If _GUICtrlStatusBar_IsSimple($hWnd) Then $iConX += $iPadX
  179. $iConY = $iBarY + $iPadY
  180. $iConW = $iBarW - ($iPadX * 2)
  181. $iConH = $iBarH - ($iPadY * 2)
  182. EndIf
  183. _WinAPI_SetParent($hControl, $hWnd)
  184. _WinAPI_MoveWindow($hControl, $iConX, $iConY, $iConW, $iConH)
  185. EndFunc ;==>_GUICtrlStatusBar_EmbedControl
  186. ; #FUNCTION# ====================================================================================================================
  187. ; Author ........: Gary Frost (gafrost)
  188. ; Modified.......:
  189. ; ===============================================================================================================================
  190. Func _GUICtrlStatusBar_GetBorders($hWnd)
  191. Local $tBorders = DllStructCreate($tagBORDERS)
  192. Local $iRet
  193. If _WinAPI_InProcess($hWnd, $__g_hSBLastWnd) Then
  194. $iRet = _SendMessage($hWnd, $SB_GETBORDERS, 0, $tBorders, 0, "wparam", "struct*")
  195. Else
  196. Local $iSize = DllStructGetSize($tBorders)
  197. Local $tMemMap
  198. Local $pMemory = _MemInit($hWnd, $iSize, $tMemMap)
  199. $iRet = _SendMessage($hWnd, $SB_GETBORDERS, 0, $pMemory, 0, "wparam", "ptr")
  200. _MemRead($tMemMap, $pMemory, $tBorders, $iSize)
  201. _MemFree($tMemMap)
  202. EndIf
  203. Local $aBorders[3]
  204. If $iRet = 0 Then Return SetError(-1, -1, $aBorders)
  205. $aBorders[0] = DllStructGetData($tBorders, "BX")
  206. $aBorders[1] = DllStructGetData($tBorders, "BY")
  207. $aBorders[2] = DllStructGetData($tBorders, "RX")
  208. Return $aBorders
  209. EndFunc ;==>_GUICtrlStatusBar_GetBorders
  210. ; #FUNCTION# ====================================================================================================================
  211. ; Author ........: Paul Campbell (PaulIA)
  212. ; Modified.......:
  213. ; ===============================================================================================================================
  214. Func _GUICtrlStatusBar_GetBordersHorz($hWnd)
  215. Local $aBorders = _GUICtrlStatusBar_GetBorders($hWnd)
  216. Return SetError(@error, @extended, $aBorders[0])
  217. EndFunc ;==>_GUICtrlStatusBar_GetBordersHorz
  218. ; #FUNCTION# ====================================================================================================================
  219. ; Author ........: Paul Campbell (PaulIA)
  220. ; Modified.......:
  221. ; ===============================================================================================================================
  222. Func _GUICtrlStatusBar_GetBordersRect($hWnd)
  223. Local $aBorders = _GUICtrlStatusBar_GetBorders($hWnd)
  224. Return SetError(@error, @extended, $aBorders[2])
  225. EndFunc ;==>_GUICtrlStatusBar_GetBordersRect
  226. ; #FUNCTION# ====================================================================================================================
  227. ; Author ........: Paul Campbell (PaulIA)
  228. ; Modified.......:
  229. ; ===============================================================================================================================
  230. Func _GUICtrlStatusBar_GetBordersVert($hWnd)
  231. Local $aBorders = _GUICtrlStatusBar_GetBorders($hWnd)
  232. Return SetError(@error, @extended, $aBorders[1])
  233. EndFunc ;==>_GUICtrlStatusBar_GetBordersVert
  234. ; #FUNCTION# ====================================================================================================================
  235. ; Author ........: Gary Frost (gafrost)
  236. ; Modified.......:
  237. ; ===============================================================================================================================
  238. Func _GUICtrlStatusBar_GetCount($hWnd)
  239. Return _SendMessage($hWnd, $SB_GETPARTS)
  240. EndFunc ;==>_GUICtrlStatusBar_GetCount
  241. ; #FUNCTION# ====================================================================================================================
  242. ; Author ........: Paul Campbell (PaulIA)
  243. ; Modified.......: Gary Frost (gafrost) Removed dot notation
  244. ; ===============================================================================================================================
  245. Func _GUICtrlStatusBar_GetHeight($hWnd)
  246. Local $tRECT = _GUICtrlStatusBar_GetRectEx($hWnd, 0)
  247. Return DllStructGetData($tRECT, "Bottom") - DllStructGetData($tRECT, "Top") - (_GUICtrlStatusBar_GetBordersVert($hWnd) * 2)
  248. EndFunc ;==>_GUICtrlStatusBar_GetHeight
  249. ; #FUNCTION# ====================================================================================================================
  250. ; Author ........: Steve Podhajecki <gehossafats at netmdc dotcom>
  251. ; Modified.......: Gary Frost (GaryFrost)
  252. ; ===============================================================================================================================
  253. Func _GUICtrlStatusBar_GetIcon($hWnd, $iIndex = 0)
  254. Return _SendMessage($hWnd, $SB_GETICON, $iIndex, 0, 0, "wparam", "lparam", "handle")
  255. EndFunc ;==>_GUICtrlStatusBar_GetIcon
  256. ; #FUNCTION# ====================================================================================================================
  257. ; Author ........: Paul Campbell (PaulIA)
  258. ; Modified.......:
  259. ; ===============================================================================================================================
  260. Func _GUICtrlStatusBar_GetParts($hWnd)
  261. Local $iCount = _GUICtrlStatusBar_GetCount($hWnd)
  262. Local $tParts = DllStructCreate("int[" & $iCount & "]")
  263. Local $aParts[$iCount + 1]
  264. If _WinAPI_InProcess($hWnd, $__g_hSBLastWnd) Then
  265. $aParts[0] = _SendMessage($hWnd, $SB_GETPARTS, $iCount, $tParts, 0, "wparam", "struct*")
  266. Else
  267. Local $iParts = DllStructGetSize($tParts)
  268. Local $tMemMap
  269. Local $pMemory = _MemInit($hWnd, $iParts, $tMemMap)
  270. $aParts[0] = _SendMessage($hWnd, $SB_GETPARTS, $iCount, $pMemory, 0, "wparam", "ptr")
  271. _MemRead($tMemMap, $pMemory, $tParts, $iParts)
  272. _MemFree($tMemMap)
  273. EndIf
  274. For $iI = 1 To $iCount
  275. $aParts[$iI] = DllStructGetData($tParts, 1, $iI)
  276. Next
  277. Return $aParts
  278. EndFunc ;==>_GUICtrlStatusBar_GetParts
  279. ; #FUNCTION# ====================================================================================================================
  280. ; Author ........: Paul Campbell (PaulIA)
  281. ; Modified.......:
  282. ; ===============================================================================================================================
  283. Func _GUICtrlStatusBar_GetRect($hWnd, $iPart)
  284. Local $tRECT = _GUICtrlStatusBar_GetRectEx($hWnd, $iPart)
  285. If @error Then Return SetError(@error, 0, 0)
  286. Local $aRect[4]
  287. $aRect[0] = DllStructGetData($tRECT, "Left")
  288. $aRect[1] = DllStructGetData($tRECT, "Top")
  289. $aRect[2] = DllStructGetData($tRECT, "Right")
  290. $aRect[3] = DllStructGetData($tRECT, "Bottom")
  291. Return $aRect
  292. EndFunc ;==>_GUICtrlStatusBar_GetRect
  293. ; #FUNCTION# ====================================================================================================================
  294. ; Author ........: Paul Campbell (PaulIA)
  295. ; Modified.......:
  296. ; ===============================================================================================================================
  297. Func _GUICtrlStatusBar_GetRectEx($hWnd, $iPart)
  298. Local $tRECT = DllStructCreate($tagRECT)
  299. Local $iRet
  300. If _WinAPI_InProcess($hWnd, $__g_hSBLastWnd) Then
  301. $iRet = _SendMessage($hWnd, $SB_GETRECT, $iPart, $tRECT, 0, "wparam", "struct*")
  302. Else
  303. Local $iRect = DllStructGetSize($tRECT)
  304. Local $tMemMap
  305. Local $pMemory = _MemInit($hWnd, $iRect, $tMemMap)
  306. $iRet = _SendMessage($hWnd, $SB_GETRECT, $iPart, $pMemory, 0, "wparam", "ptr")
  307. _MemRead($tMemMap, $pMemory, $tRECT, $iRect)
  308. _MemFree($tMemMap)
  309. EndIf
  310. Return SetError($iRet = 0, 0, $tRECT)
  311. EndFunc ;==>_GUICtrlStatusBar_GetRectEx
  312. ; #FUNCTION# ====================================================================================================================
  313. ; Author ........: Paul Campbell (PaulIA)
  314. ; Modified.......:
  315. ; ===============================================================================================================================
  316. Func _GUICtrlStatusBar_GetText($hWnd, $iPart)
  317. Local $bUnicode = _GUICtrlStatusBar_GetUnicodeFormat($hWnd)
  318. Local $iBuffer = _GUICtrlStatusBar_GetTextLength($hWnd, $iPart) + 1
  319. If $iBuffer = 1 Then Return SetError(1, 0, "")
  320. Local $tBuffer
  321. If $bUnicode Then
  322. $tBuffer = DllStructCreate("wchar Text[" & $iBuffer & "]")
  323. $iBuffer *= 2
  324. Else
  325. $tBuffer = DllStructCreate("char Text[" & $iBuffer & "]")
  326. EndIf
  327. If _WinAPI_InProcess($hWnd, $__g_hSBLastWnd) Then
  328. _SendMessage($hWnd, $SB_GETTEXTW, $iPart, $tBuffer, 0, "wparam", "struct*")
  329. Else
  330. Local $tMemMap
  331. Local $pMemory = _MemInit($hWnd, $iBuffer, $tMemMap)
  332. If $bUnicode Then
  333. _SendMessage($hWnd, $SB_GETTEXTW, $iPart, $pMemory, 0, "wparam", "ptr")
  334. Else
  335. _SendMessage($hWnd, $SB_GETTEXT, $iPart, $pMemory, 0, "wparam", "ptr")
  336. EndIf
  337. _MemRead($tMemMap, $pMemory, $tBuffer, $iBuffer)
  338. _MemFree($tMemMap)
  339. EndIf
  340. Return DllStructGetData($tBuffer, "Text")
  341. EndFunc ;==>_GUICtrlStatusBar_GetText
  342. ; #FUNCTION# ====================================================================================================================
  343. ; Author ........: Paul Campbell (PaulIA)
  344. ; Modified.......:
  345. ; ===============================================================================================================================
  346. Func _GUICtrlStatusBar_GetTextFlags($hWnd, $iPart)
  347. If _GUICtrlStatusBar_GetUnicodeFormat($hWnd) Then
  348. Return _SendMessage($hWnd, $SB_GETTEXTLENGTHW, $iPart)
  349. Else
  350. Return _SendMessage($hWnd, $SB_GETTEXTLENGTH, $iPart)
  351. EndIf
  352. EndFunc ;==>_GUICtrlStatusBar_GetTextFlags
  353. ; #FUNCTION# ====================================================================================================================
  354. ; Author ........: Paul Campbell (PaulIA)
  355. ; Modified.......:
  356. ; ===============================================================================================================================
  357. Func _GUICtrlStatusBar_GetTextLength($hWnd, $iPart)
  358. Return _WinAPI_LoWord(_GUICtrlStatusBar_GetTextFlags($hWnd, $iPart))
  359. EndFunc ;==>_GUICtrlStatusBar_GetTextLength
  360. ; #FUNCTION# ====================================================================================================================
  361. ; Author ........: Gary Frost (gafrost
  362. ; Modified.......:
  363. ; ===============================================================================================================================
  364. Func _GUICtrlStatusBar_GetTextLengthEx($hWnd, $iPart)
  365. Return _WinAPI_HiWord(_GUICtrlStatusBar_GetTextFlags($hWnd, $iPart))
  366. EndFunc ;==>_GUICtrlStatusBar_GetTextLengthEx
  367. ; #FUNCTION# ====================================================================================================================
  368. ; Author ........: Paul Campbell (PaulIA)
  369. ; Modified.......: Gary Frost (GaryFrost)
  370. ; ===============================================================================================================================
  371. Func _GUICtrlStatusBar_GetTipText($hWnd, $iPart)
  372. Local $bUnicode = _GUICtrlStatusBar_GetUnicodeFormat($hWnd)
  373. Local $tBuffer
  374. If $bUnicode Then
  375. $tBuffer = DllStructCreate("wchar Text[4096]")
  376. Else
  377. $tBuffer = DllStructCreate("char Text[4096]")
  378. EndIf
  379. If _WinAPI_InProcess($hWnd, $__g_hSBLastWnd) Then
  380. _SendMessage($hWnd, $SB_GETTIPTEXTW, _WinAPI_MakeLong($iPart, 4096), $tBuffer, 0, "wparam", "struct*")
  381. Else
  382. Local $tMemMap
  383. Local $pMemory = _MemInit($hWnd, 4096, $tMemMap)
  384. If $bUnicode Then
  385. _SendMessage($hWnd, $SB_GETTIPTEXTW, _WinAPI_MakeLong($iPart, 4096), $pMemory, 0, "wparam", "ptr")
  386. Else
  387. _SendMessage($hWnd, $SB_GETTIPTEXTA, _WinAPI_MakeLong($iPart, 4096), $pMemory, 0, "wparam", "ptr")
  388. EndIf
  389. _MemRead($tMemMap, $pMemory, $tBuffer, 4096)
  390. _MemFree($tMemMap)
  391. EndIf
  392. Return DllStructGetData($tBuffer, "Text")
  393. EndFunc ;==>_GUICtrlStatusBar_GetTipText
  394. ; #FUNCTION# ====================================================================================================================
  395. ; Author ........: Gary Frost (gafrost)
  396. ; Modified.......:
  397. ; ===============================================================================================================================
  398. Func _GUICtrlStatusBar_GetUnicodeFormat($hWnd)
  399. Return _SendMessage($hWnd, $SB_GETUNICODEFORMAT) <> 0
  400. EndFunc ;==>_GUICtrlStatusBar_GetUnicodeFormat
  401. ; #FUNCTION# ====================================================================================================================
  402. ; Author ........: Paul Campbell (PaulIA)
  403. ; Modified.......: Gary Frost (gafrost) Removed dot notation
  404. ; ===============================================================================================================================
  405. Func _GUICtrlStatusBar_GetWidth($hWnd, $iPart)
  406. Local $tRECT = _GUICtrlStatusBar_GetRectEx($hWnd, $iPart)
  407. Return DllStructGetData($tRECT, "Right") - DllStructGetData($tRECT, "Left") - (_GUICtrlStatusBar_GetBordersHorz($hWnd) * 2)
  408. EndFunc ;==>_GUICtrlStatusBar_GetWidth
  409. ; #FUNCTION# ====================================================================================================================
  410. ; Author ........: Gary Frost (gafrost)
  411. ; Modified.......:
  412. ; ===============================================================================================================================
  413. Func _GUICtrlStatusBar_IsSimple($hWnd)
  414. Return _SendMessage($hWnd, $SB_ISSIMPLE) <> 0
  415. EndFunc ;==>_GUICtrlStatusBar_IsSimple
  416. ; #FUNCTION# ====================================================================================================================
  417. ; Author ........: Paul Campbell (PaulIA)
  418. ; Modified.......:
  419. ; ===============================================================================================================================
  420. Func _GUICtrlStatusBar_Resize($hWnd)
  421. _SendMessage($hWnd, $__STATUSBARCONSTANT_WM_SIZE)
  422. EndFunc ;==>_GUICtrlStatusBar_Resize
  423. ; #FUNCTION# ====================================================================================================================
  424. ; Author ........: Paul Campbell (PaulIA)
  425. ; Modified.......: Gary Frost (gafrost), jpm
  426. ; ===============================================================================================================================
  427. Func _GUICtrlStatusBar_SetBkColor($hWnd, $iColor)
  428. $iColor = _SendMessage($hWnd, $SB_SETBKCOLOR, 0, $iColor)
  429. EndFunc ;==>_GUICtrlStatusBar_SetBkColor
  430. ; #FUNCTION# ====================================================================================================================
  431. ; Author ........: Gary Frost (gafrost)
  432. ; Modified.......:
  433. ; ===============================================================================================================================
  434. Func _GUICtrlStatusBar_SetIcon($hWnd, $iPart, $hIcon = -1, $sIconFile = "")
  435. If $hIcon = -1 Then Return _SendMessage($hWnd, $SB_SETICON, $iPart, $hIcon, 0, "wparam", "handle") <> 0 ; Remove Icon
  436. If StringLen($sIconFile) <= 0 Then Return _SendMessage($hWnd, $SB_SETICON, $iPart, $hIcon) <> 0 ; set icon from icon handle
  437. ; set icon from file
  438. Local $tIcon = DllStructCreate("handle")
  439. Local $vResult = DllCall("shell32.dll", "uint", "ExtractIconExW", "wstr", $sIconFile, "int", $hIcon, "ptr", 0, "struct*", $tIcon, "uint", 1)
  440. If @error Then Return SetError(@error, @extended, False)
  441. $vResult = $vResult[0]
  442. If $vResult > 0 Then $vResult = _SendMessage($hWnd, $SB_SETICON, $iPart, DllStructGetData($tIcon, 1), 0, "wparam", "handle")
  443. DllCall("user32.dll", "bool", "DestroyIcon", "handle", DllStructGetData($tIcon, 1))
  444. ; No need to test @error.
  445. Return $vResult
  446. EndFunc ;==>_GUICtrlStatusBar_SetIcon
  447. ; #FUNCTION# ====================================================================================================================
  448. ; Author ........: Gary Frost (gafrost)
  449. ; Modified.......:
  450. ; ===============================================================================================================================
  451. Func _GUICtrlStatusBar_SetMinHeight($hWnd, $iMinHeight)
  452. _SendMessage($hWnd, $SB_SETMINHEIGHT, $iMinHeight)
  453. _GUICtrlStatusBar_Resize($hWnd)
  454. EndFunc ;==>_GUICtrlStatusBar_SetMinHeight
  455. ; #FUNCTION# ====================================================================================================================
  456. ; Author ........: Gary Frost (gafrost)
  457. ; Modified.......:
  458. ; ===============================================================================================================================
  459. Func _GUICtrlStatusBar_SetParts($hWnd, $vPartEdge = -1, $vPartWidth = 25)
  460. If IsArray($vPartEdge) And IsArray($vPartWidth) Then Return False
  461. ;== start sizing parts
  462. Local $tParts, $iParts
  463. If IsArray($vPartEdge) Then ; adding array of parts (contains widths)
  464. $vPartEdge[UBound($vPartEdge) - 1] = -1
  465. $iParts = UBound($vPartEdge)
  466. $tParts = DllStructCreate("int[" & $iParts & "]")
  467. For $x = 0 To $iParts - 2
  468. DllStructSetData($tParts, 1, $vPartEdge[$x], $x + 1)
  469. Next
  470. DllStructSetData($tParts, 1, -1, $iParts)
  471. Else
  472. If $vPartEdge < -1 Then Return False
  473. If IsArray($vPartWidth) Then ; adding array of part widths (make parts an array)
  474. $iParts = UBound($vPartWidth)
  475. $tParts = DllStructCreate("int[" & $iParts & "]")
  476. Local $iPartRightEdge = 0
  477. For $x = 0 To $iParts - 2
  478. $iPartRightEdge += $vPartWidth[$x]
  479. If $vPartWidth[$x] <= 0 Then Return False
  480. DllStructSetData($tParts, 1, $iPartRightEdge, $x + 1)
  481. Next
  482. DllStructSetData($tParts, 1, -1, $iParts)
  483. ElseIf $vPartEdge > 1 Then ; adding parts with default width
  484. $iParts = $vPartEdge
  485. $tParts = DllStructCreate("int[" & $iParts & "]")
  486. For $x = 1 To $iParts - 1
  487. DllStructSetData($tParts, 1, $vPartWidth * $x, $x)
  488. Next
  489. DllStructSetData($tParts, 1, -1, $iParts)
  490. Else ; defaulting to 1 part
  491. $iParts = 1
  492. $tParts = DllStructCreate("int")
  493. DllStructSetData($tParts, 1, -1)
  494. EndIf
  495. EndIf
  496. ;== end set sizing
  497. If _WinAPI_InProcess($hWnd, $__g_hSBLastWnd) Then
  498. _SendMessage($hWnd, $SB_SETPARTS, $iParts, $tParts, 0, "wparam", "struct*")
  499. Else
  500. Local $iSize = DllStructGetSize($tParts)
  501. Local $tMemMap
  502. Local $pMemory = _MemInit($hWnd, $iSize, $tMemMap)
  503. _MemWrite($tMemMap, $tParts)
  504. _SendMessage($hWnd, $SB_SETPARTS, $iParts, $pMemory, 0, "wparam", "ptr")
  505. _MemFree($tMemMap)
  506. EndIf
  507. _GUICtrlStatusBar_Resize($hWnd)
  508. Return True
  509. EndFunc ;==>_GUICtrlStatusBar_SetParts
  510. ; #FUNCTION# ====================================================================================================================
  511. ; Author ........: Gary Frost (gafrost)
  512. ; Modified.......:
  513. ; ===============================================================================================================================
  514. Func _GUICtrlStatusBar_SetSimple($hWnd, $bSimple = True)
  515. _SendMessage($hWnd, $SB_SIMPLE, $bSimple)
  516. EndFunc ;==>_GUICtrlStatusBar_SetSimple
  517. ; #FUNCTION# ====================================================================================================================
  518. ; Author ........: rysiora, JdeB, tonedef, Gary Frost (gafrost)
  519. ; Modified.......: Gary Frost (gafrost) re-written also added $iUFlag
  520. ; ===============================================================================================================================
  521. Func _GUICtrlStatusBar_SetText($hWnd, $sText = "", $iPart = 0, $iUFlag = 0)
  522. Local $bUnicode = _GUICtrlStatusBar_GetUnicodeFormat($hWnd)
  523. Local $iBuffer = StringLen($sText) + 1
  524. Local $tText
  525. If $bUnicode Then
  526. $tText = DllStructCreate("wchar Text[" & $iBuffer & "]")
  527. $iBuffer *= 2
  528. Else
  529. $tText = DllStructCreate("char Text[" & $iBuffer & "]")
  530. EndIf
  531. DllStructSetData($tText, "Text", $sText)
  532. If _GUICtrlStatusBar_IsSimple($hWnd) Then $iPart = $SB_SIMPLEID
  533. Local $iRet
  534. If _WinAPI_InProcess($hWnd, $__g_hSBLastWnd) Then
  535. $iRet = _SendMessage($hWnd, $SB_SETTEXTW, BitOR($iPart, $iUFlag), $tText, 0, "wparam", "struct*")
  536. Else
  537. Local $tMemMap
  538. Local $pMemory = _MemInit($hWnd, $iBuffer, $tMemMap)
  539. _MemWrite($tMemMap, $tText)
  540. If $bUnicode Then
  541. $iRet = _SendMessage($hWnd, $SB_SETTEXTW, BitOR($iPart, $iUFlag), $pMemory, 0, "wparam", "ptr")
  542. Else
  543. $iRet = _SendMessage($hWnd, $SB_SETTEXT, BitOR($iPart, $iUFlag), $pMemory, 0, "wparam", "ptr")
  544. EndIf
  545. _MemFree($tMemMap)
  546. EndIf
  547. Return $iRet <> 0
  548. EndFunc ;==>_GUICtrlStatusBar_SetText
  549. ; #FUNCTION# ====================================================================================================================
  550. ; Author ........: Gary Frost (gafrost)
  551. ; Modified.......:
  552. ; ===============================================================================================================================
  553. Func _GUICtrlStatusBar_SetTipText($hWnd, $iPart, $sText)
  554. Local $bUnicode = _GUICtrlStatusBar_GetUnicodeFormat($hWnd)
  555. Local $iBuffer = StringLen($sText) + 1
  556. Local $tText
  557. If $bUnicode Then
  558. $tText = DllStructCreate("wchar TipText[" & $iBuffer & "]")
  559. $iBuffer *= 2
  560. Else
  561. $tText = DllStructCreate("char TipText[" & $iBuffer & "]")
  562. EndIf
  563. DllStructSetData($tText, "TipText", $sText)
  564. If _WinAPI_InProcess($hWnd, $__g_hSBLastWnd) Then
  565. _SendMessage($hWnd, $SB_SETTIPTEXTW, $iPart, $tText, 0, "wparam", "struct*")
  566. Else
  567. Local $tMemMap
  568. Local $pMemory = _MemInit($hWnd, $iBuffer, $tMemMap)
  569. _MemWrite($tMemMap, $tText, $pMemory, $iBuffer)
  570. If $bUnicode Then
  571. _SendMessage($hWnd, $SB_SETTIPTEXTW, $iPart, $pMemory, 0, "wparam", "ptr")
  572. Else
  573. _SendMessage($hWnd, $SB_SETTIPTEXTA, $iPart, $pMemory, 0, "wparam", "ptr")
  574. EndIf
  575. _MemFree($tMemMap)
  576. EndIf
  577. EndFunc ;==>_GUICtrlStatusBar_SetTipText
  578. ; #FUNCTION# ====================================================================================================================
  579. ; Author ........: Gary Frost (gafrost)
  580. ; Modified.......:
  581. ; ===============================================================================================================================
  582. Func _GUICtrlStatusBar_SetUnicodeFormat($hWnd, $bUnicode = True)
  583. Return _SendMessage($hWnd, $SB_SETUNICODEFORMAT, $bUnicode)
  584. EndFunc ;==>_GUICtrlStatusBar_SetUnicodeFormat
  585. ; #FUNCTION# ====================================================================================================================
  586. ; Author ........: Gary Frost (gafrost)
  587. ; Modified.......:
  588. ; ===============================================================================================================================
  589. Func _GUICtrlStatusBar_ShowHide($hWnd, $iState)
  590. If $iState <> @SW_HIDE And $iState <> @SW_SHOW Then Return SetError(1, 1, False)
  591. Return _WinAPI_ShowWindow($hWnd, $iState)
  592. EndFunc ;==>_GUICtrlStatusBar_ShowHide