GuiMonthCal.au3 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906
  1. #include-once
  2. #include "DateTimeConstants.au3"
  3. #include "Memory.au3"
  4. #include "SendMessage.au3"
  5. #include "StructureConstants.au3"
  6. #include "UDFGlobalID.au3"
  7. #include "WinAPIConv.au3"
  8. ;~ #include "WinAPIMisc.au3"
  9. #include "WinAPISysInternals.au3"
  10. ; #INDEX# =======================================================================================================================
  11. ; Title .........: MonthCalendar
  12. ; AutoIt Version : 3.3.14.5
  13. ; Language ......: English
  14. ; Description ...: Functions that assist with MonthCalendar control management.
  15. ; A month calendar control implements a calendar-like user interface. This provides the user with a very
  16. ; intuitive and recognizable method of entering or selecting a date. The control also provides the application
  17. ; with the means to obtain and set the date information in the control using existing data types.
  18. ; Author(s) .....: Paul Campbell (PaulIA), Gary Frost (gafrost)
  19. ; ===============================================================================================================================
  20. ; #VARIABLES# ===================================================================================================================
  21. Global $__g_hMCLastWnd
  22. ; ===============================================================================================================================
  23. ; #CONSTANTS# ===================================================================================================================
  24. Global Const $__MONTHCALCONSTANT_ClassName = "SysMonthCal32"
  25. Global Const $__MONTHCALCONSTANT_SWP_NOZORDER = 0x0004
  26. ; ===============================================================================================================================$aArray[$i]
  27. ; #CURRENT# =====================================================================================================================
  28. ; _GUICtrlMonthCal_Create
  29. ; _GUICtrlMonthCal_Destroy
  30. ; _GUICtrlMonthCal_GetCalendarBorder
  31. ; _GUICtrlMonthCal_GetCalendarCount
  32. ; _GUICtrlMonthCal_GetColor
  33. ; _GUICtrlMonthCal_GetColorArray
  34. ; _GUICtrlMonthCal_GetCurSel
  35. ; _GUICtrlMonthCal_GetCurSelStr
  36. ; _GUICtrlMonthCal_GetFirstDOW
  37. ; _GUICtrlMonthCal_GetFirstDOWStr
  38. ; _GUICtrlMonthCal_GetMaxSelCount
  39. ; _GUICtrlMonthCal_GetMaxTodayWidth
  40. ; _GUICtrlMonthCal_GetMinReqHeight
  41. ; _GUICtrlMonthCal_GetMinReqRect
  42. ; _GUICtrlMonthCal_GetMinReqRectArray
  43. ; _GUICtrlMonthCal_GetMinReqWidth
  44. ; _GUICtrlMonthCal_GetMonthDelta
  45. ; _GUICtrlMonthCal_GetMonthRange
  46. ; _GUICtrlMonthCal_GetMonthRangeMax
  47. ; _GUICtrlMonthCal_GetMonthRangeMaxStr
  48. ; _GUICtrlMonthCal_GetMonthRangeMin
  49. ; _GUICtrlMonthCal_GetMonthRangeMinStr
  50. ; _GUICtrlMonthCal_GetMonthRangeSpan
  51. ; _GUICtrlMonthCal_GetRange
  52. ; _GUICtrlMonthCal_GetRangeMax
  53. ; _GUICtrlMonthCal_GetRangeMaxStr
  54. ; _GUICtrlMonthCal_GetRangeMin
  55. ; _GUICtrlMonthCal_GetRangeMinStr
  56. ; _GUICtrlMonthCal_GetSelRange
  57. ; _GUICtrlMonthCal_GetSelRangeMax
  58. ; _GUICtrlMonthCal_GetSelRangeMaxStr
  59. ; _GUICtrlMonthCal_GetSelRangeMin
  60. ; _GUICtrlMonthCal_GetSelRangeMinStr
  61. ; _GUICtrlMonthCal_GetToday
  62. ; _GUICtrlMonthCal_GetTodayStr
  63. ; _GUICtrlMonthCal_GetUnicodeFormat
  64. ; _GUICtrlMonthCal_HitTest
  65. ; _GUICtrlMonthCal_SetCalendarBorder
  66. ; _GUICtrlMonthCal_SetColor
  67. ; _GUICtrlMonthCal_SetCurSel
  68. ; _GUICtrlMonthCal_SetDayState
  69. ; _GUICtrlMonthCal_SetFirstDOW
  70. ; _GUICtrlMonthCal_SetMaxSelCount
  71. ; _GUICtrlMonthCal_SetMonthDelta
  72. ; _GUICtrlMonthCal_SetRange
  73. ; _GUICtrlMonthCal_SetSelRange
  74. ; _GUICtrlMonthCal_SetToday
  75. ; _GUICtrlMonthCal_SetUnicodeFormat
  76. ; ===============================================================================================================================
  77. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  78. ; __GUICtrlMonthCal_Resize
  79. ; ===============================================================================================================================
  80. ; #FUNCTION# ====================================================================================================================
  81. ; Author ........: Paul Campbell (PaulIA)
  82. ; Modified.......: Gary Frost
  83. ; ===============================================================================================================================
  84. Func _GUICtrlMonthCal_Create($hWnd, $iX, $iY, $iStyle = 0x00000000, $iExStyle = 0x00000000)
  85. If Not IsHWnd($hWnd) Then
  86. ; Invalid Window handle for _GUICtrlMonthCal_Create 1st parameter
  87. Return SetError(1, 0, 0)
  88. EndIf
  89. Local $hMonCal, $nCtrlID
  90. If $iStyle = -1 Then $iStyle = 0x00000000
  91. If $iExStyle = -1 Then $iExStyle = 0x00000000
  92. $iStyle = BitOR($iStyle, $__UDFGUICONSTANT_WS_CHILD, $__UDFGUICONSTANT_WS_VISIBLE)
  93. $nCtrlID = __UDF_GetNextGlobalID($hWnd)
  94. If @error Then Return SetError(@error, @extended, 0)
  95. $hMonCal = _WinAPI_CreateWindowEx($iExStyle, $__MONTHCALCONSTANT_ClassName, "", $iStyle, $iX, $iY, 0, 0, $hWnd, $nCtrlID)
  96. __GUICtrlMonthCal_Resize($hMonCal, $iX, $iY)
  97. Return $hMonCal
  98. EndFunc ;==>_GUICtrlMonthCal_Create
  99. ; #FUNCTION# ====================================================================================================================
  100. ; Author ........: Gary Frost (gafrost)
  101. ; Modified.......:
  102. ; ===============================================================================================================================
  103. Func _GUICtrlMonthCal_Destroy(ByRef $hWnd)
  104. If Not _WinAPI_IsClassName($hWnd, $__MONTHCALCONSTANT_ClassName) Then Return SetError(2, 2, False)
  105. Local $iDestroyed = 0
  106. If IsHWnd($hWnd) Then
  107. If _WinAPI_InProcess($hWnd, $__g_hMCLastWnd) Then
  108. Local $nCtrlID = _WinAPI_GetDlgCtrlID($hWnd)
  109. Local $hParent = _WinAPI_GetParent($hWnd)
  110. $iDestroyed = _WinAPI_DestroyWindow($hWnd)
  111. Local $iRet = __UDF_FreeGlobalID($hParent, $nCtrlID)
  112. If Not $iRet Then
  113. ; can check for errors here if needed, for debug
  114. EndIf
  115. Else
  116. ; Not Allowed to Delete Other Applications Month Calendar(s) Control(s)
  117. Return SetError(1, 1, False)
  118. EndIf
  119. Else
  120. $iDestroyed = GUICtrlDelete($hWnd)
  121. EndIf
  122. If $iDestroyed Then $hWnd = 0
  123. Return $iDestroyed <> 0
  124. EndFunc ;==>_GUICtrlMonthCal_Destroy
  125. ; #FUNCTION# ====================================================================================================================
  126. ; Author ........: Gary Frost
  127. ; Modified.......:
  128. ; ===============================================================================================================================
  129. Func _GUICtrlMonthCal_GetCalendarBorder($hWnd)
  130. If IsHWnd($hWnd) Then
  131. Return _SendMessage($hWnd, $MCM_GETCALENDARBORDER)
  132. Else
  133. Return GUICtrlSendMsg($hWnd, $MCM_GETCALENDARBORDER, 0, 0)
  134. EndIf
  135. EndFunc ;==>_GUICtrlMonthCal_GetCalendarBorder
  136. ; #FUNCTION# ====================================================================================================================
  137. ; Author ........: Gary Frost
  138. ; Modified.......:
  139. ; ===============================================================================================================================
  140. Func _GUICtrlMonthCal_GetCalendarCount($hWnd)
  141. If IsHWnd($hWnd) Then
  142. Return _SendMessage($hWnd, $MCM_GETCALENDARCOUNT)
  143. Else
  144. Return GUICtrlSendMsg($hWnd, $MCM_GETCALENDARCOUNT, 0, 0)
  145. EndIf
  146. EndFunc ;==>_GUICtrlMonthCal_GetCalendarCount
  147. ; #FUNCTION# ====================================================================================================================
  148. ; Author ........: Paul Campbell (PaulIA)
  149. ; Modified.......: Gary Frost (gafrost)
  150. ; ===============================================================================================================================
  151. Func _GUICtrlMonthCal_GetColor($hWnd, $iIndex)
  152. If IsHWnd($hWnd) Then
  153. Return _SendMessage($hWnd, $MCM_GETCOLOR, $iIndex)
  154. Else
  155. Return GUICtrlSendMsg($hWnd, $MCM_GETCOLOR, $iIndex, 0)
  156. EndIf
  157. EndFunc ;==>_GUICtrlMonthCal_GetColor
  158. ; #FUNCTION# ====================================================================================================================
  159. ; Author ........: Gary Frost (gafrost)
  160. ; Modified.......:
  161. ; ===============================================================================================================================
  162. Func _GUICtrlMonthCal_GetColorArray($hWnd, $iColor)
  163. Local $iRet, $a_Result[4]
  164. $a_Result[0] = 3
  165. If IsHWnd($hWnd) Then
  166. $iRet = _SendMessage($hWnd, $MCM_GETCOLOR, $iColor)
  167. Else
  168. $iRet = GUICtrlSendMsg($hWnd, $MCM_GETCOLOR, $iColor, 0)
  169. EndIf
  170. If $iRet = -1 Then Return SetError(1, $iRet, 0)
  171. $a_Result[1] = Int($iRet) ; COLORREF rgbcolor
  172. $a_Result[2] = "0x" & Hex(String($iRet), 6) ; Hex BGR color
  173. $a_Result[3] = Hex(String($iRet), 6)
  174. $a_Result[3] = "0x" & StringMid($a_Result[3], 5, 2) & StringMid($a_Result[3], 3, 2) & StringMid($a_Result[3], 1, 2) ; Hex RGB Color
  175. Return $a_Result
  176. EndFunc ;==>_GUICtrlMonthCal_GetColorArray
  177. ; #FUNCTION# ====================================================================================================================
  178. ; Author ........: Paul Campbell (PaulIA)
  179. ; Modified.......: Gary Frost (gafrost)
  180. ; ===============================================================================================================================
  181. Func _GUICtrlMonthCal_GetCurSel($hWnd)
  182. Local $tBuffer = DllStructCreate($tagSYSTEMTIME)
  183. If IsHWnd($hWnd) Then
  184. If _WinAPI_InProcess($hWnd, $__g_hMCLastWnd) Then
  185. _SendMessage($hWnd, $MCM_GETCURSEL, 0, $tBuffer, 0, "wparam", "struct*")
  186. Else
  187. Local $iBuffer = DllStructGetSize($tBuffer)
  188. Local $tMemMap
  189. Local $pMemory = _MemInit($hWnd, $iBuffer, $tMemMap)
  190. _SendMessage($hWnd, $MCM_GETCURSEL, 0, $pMemory, 0, "wparam", "ptr")
  191. _MemRead($tMemMap, $pMemory, $tBuffer, $iBuffer)
  192. _MemFree($tMemMap)
  193. EndIf
  194. Else
  195. GUICtrlSendMsg($hWnd, $MCM_GETCURSEL, 0, DllStructGetPtr($tBuffer))
  196. EndIf
  197. Return $tBuffer
  198. EndFunc ;==>_GUICtrlMonthCal_GetCurSel
  199. ; #FUNCTION# ====================================================================================================================
  200. ; Author ........: Paul Campbell (PaulIA)
  201. ; Modified.......:
  202. ; ===============================================================================================================================
  203. Func _GUICtrlMonthCal_GetCurSelStr($hWnd, $sFormat = "%02d/%02d/%04d")
  204. Local $tBuffer = _GUICtrlMonthCal_GetCurSel($hWnd)
  205. Return StringFormat($sFormat, DllStructGetData($tBuffer, "Month"), DllStructGetData($tBuffer, "Day"), DllStructGetData($tBuffer, "Year"))
  206. EndFunc ;==>_GUICtrlMonthCal_GetCurSelStr
  207. ; #FUNCTION# ====================================================================================================================
  208. ; Author ........: Paul Campbell (PaulIA)
  209. ; Modified.......: Gary Frost (gafrost)
  210. ; ===============================================================================================================================
  211. Func _GUICtrlMonthCal_GetFirstDOW($hWnd)
  212. If IsHWnd($hWnd) Then
  213. Return _WinAPI_LoWord(_SendMessage($hWnd, $MCM_GETFIRSTDAYOFWEEK))
  214. Else
  215. Return _WinAPI_LoWord(GUICtrlSendMsg($hWnd, $MCM_GETFIRSTDAYOFWEEK, 0, 0))
  216. EndIf
  217. EndFunc ;==>_GUICtrlMonthCal_GetFirstDOW
  218. ; #FUNCTION# ====================================================================================================================
  219. ; Author ........: Paul Campbell (PaulIA)
  220. ; Modified.......:
  221. ; ===============================================================================================================================
  222. Func _GUICtrlMonthCal_GetFirstDOWStr($hWnd)
  223. Local $aDays[7] = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"]
  224. Return $aDays[_GUICtrlMonthCal_GetFirstDOW($hWnd)]
  225. EndFunc ;==>_GUICtrlMonthCal_GetFirstDOWStr
  226. ; #FUNCTION# ====================================================================================================================
  227. ; Author ........: Gary Frost (gafrost)
  228. ; Modified.......:
  229. ; ===============================================================================================================================
  230. Func _GUICtrlMonthCal_GetMaxSelCount($hWnd)
  231. If IsHWnd($hWnd) Then
  232. Return _SendMessage($hWnd, $MCM_GETMAXSELCOUNT)
  233. Else
  234. Return GUICtrlSendMsg($hWnd, $MCM_GETMAXSELCOUNT, 0, 0)
  235. EndIf
  236. EndFunc ;==>_GUICtrlMonthCal_GetMaxSelCount
  237. ; #FUNCTION# ====================================================================================================================
  238. ; Author ........: Gary Frost (gafrost)
  239. ; Modified.......:
  240. ; ===============================================================================================================================
  241. Func _GUICtrlMonthCal_GetMaxTodayWidth($hWnd)
  242. If IsHWnd($hWnd) Then
  243. Return _SendMessage($hWnd, $MCM_GETMAXTODAYWIDTH)
  244. Else
  245. Return GUICtrlSendMsg($hWnd, $MCM_GETMAXTODAYWIDTH, 0, 0)
  246. EndIf
  247. EndFunc ;==>_GUICtrlMonthCal_GetMaxTodayWidth
  248. ; #FUNCTION# ====================================================================================================================
  249. ; Author ........: Paul Campbell (PaulIA)
  250. ; Modified.......:
  251. ; ===============================================================================================================================
  252. Func _GUICtrlMonthCal_GetMinReqHeight($hWnd)
  253. Local $tRECT = _GUICtrlMonthCal_GetMinReqRect($hWnd)
  254. Return DllStructGetData($tRECT, "Bottom")
  255. EndFunc ;==>_GUICtrlMonthCal_GetMinReqHeight
  256. ; #FUNCTION# ====================================================================================================================
  257. ; Author ........: Paul Campbell (PaulIA)
  258. ; Modified.......: Gary Frost (gafrost)
  259. ; ===============================================================================================================================
  260. Func _GUICtrlMonthCal_GetMinReqRect($hWnd)
  261. Local $tRECT = DllStructCreate($tagRECT)
  262. If IsHWnd($hWnd) Then
  263. If _WinAPI_InProcess($hWnd, $__g_hMCLastWnd) Then
  264. _SendMessage($hWnd, $MCM_GETMINREQRECT, 0, $tRECT, 0, "wparam", "struct*")
  265. Else
  266. Local $iRect = DllStructGetSize($tRECT)
  267. Local $tMemMap
  268. Local $pMemory = _MemInit($hWnd, $iRect, $tMemMap)
  269. _SendMessage($hWnd, $MCM_GETMINREQRECT, 0, $pMemory, 0, "wparam", "ptr")
  270. _MemRead($tMemMap, $pMemory, $tRECT, $iRect)
  271. _MemFree($tMemMap)
  272. EndIf
  273. Else
  274. GUICtrlSendMsg($hWnd, $MCM_GETMINREQRECT, 0, DllStructGetPtr($tRECT))
  275. EndIf
  276. Return $tRECT
  277. EndFunc ;==>_GUICtrlMonthCal_GetMinReqRect
  278. ; #FUNCTION# ====================================================================================================================
  279. ; Author ........: Gary Frost (gafrost)
  280. ; Modified.......:
  281. ; ===============================================================================================================================
  282. Func _GUICtrlMonthCal_GetMinReqRectArray($hWnd)
  283. Local $i_Ret
  284. Local $tRECT = DllStructCreate($tagRECT)
  285. If @error Then Return SetError(-1, -1, -1)
  286. If IsHWnd($hWnd) Then
  287. $i_Ret = _SendMessage($hWnd, $MCM_GETMINREQRECT, 0, $tRECT, 0, "wparam", "struct*")
  288. Else
  289. $i_Ret = GUICtrlSendMsg($hWnd, $MCM_GETMINREQRECT, 0, DllStructGetPtr($tRECT))
  290. EndIf
  291. If (Not $i_Ret) Then Return SetError(-2, -1, -1)
  292. Return StringSplit(DllStructGetData($tRECT, "Left") & "," & DllStructGetData($tRECT, "Top") & "," & DllStructGetData($tRECT, "Right") & "," & DllStructGetData($tRECT, "Bottom"), ",")
  293. EndFunc ;==>_GUICtrlMonthCal_GetMinReqRectArray
  294. ; #FUNCTION# ====================================================================================================================
  295. ; Author ........: Paul Campbell (PaulIA)
  296. ; Modified.......:
  297. ; ===============================================================================================================================
  298. Func _GUICtrlMonthCal_GetMinReqWidth($hWnd)
  299. Local $tRECT = _GUICtrlMonthCal_GetMinReqRect($hWnd)
  300. Return DllStructGetData($tRECT, "Right")
  301. EndFunc ;==>_GUICtrlMonthCal_GetMinReqWidth
  302. ; #FUNCTION# ====================================================================================================================
  303. ; Author ........: Gary Frost (gafrost)
  304. ; Modified.......:
  305. ; ===============================================================================================================================
  306. Func _GUICtrlMonthCal_GetMonthDelta($hWnd)
  307. If IsHWnd($hWnd) Then
  308. Return _SendMessage($hWnd, $MCM_GETMONTHDELTA)
  309. Else
  310. Return GUICtrlSendMsg($hWnd, $MCM_GETMONTHDELTA, 0, 0)
  311. EndIf
  312. EndFunc ;==>_GUICtrlMonthCal_GetMonthDelta
  313. ; #FUNCTION# ====================================================================================================================
  314. ; Author ........: Paul Campbell (PaulIA)
  315. ; Modified.......: Gary Frost (gafrost)
  316. ; ===============================================================================================================================
  317. Func _GUICtrlMonthCal_GetMonthRange($hWnd, $bPartial = False)
  318. Local $tBuffer = DllStructCreate($tagMCMONTHRANGE)
  319. If IsHWnd($hWnd) Then
  320. If _WinAPI_InProcess($hWnd, $__g_hMCLastWnd) Then
  321. DllStructSetData($tBuffer, "Span", _SendMessage($hWnd, $MCM_GETMONTHRANGE, $bPartial, $tBuffer, 0, "wparam", "struct*"))
  322. Else
  323. Local $iBuffer = DllStructGetSize($tBuffer)
  324. Local $tMemMap
  325. Local $pMemory = _MemInit($hWnd, $iBuffer, $tMemMap)
  326. DllStructSetData($tBuffer, "Span", _SendMessage($hWnd, $MCM_GETMONTHRANGE, $bPartial, $pMemory, 0, "wparam", "ptr"))
  327. _MemRead($tMemMap, $pMemory, $tBuffer, $iBuffer)
  328. _MemFree($tMemMap)
  329. EndIf
  330. Else
  331. DllStructSetData($tBuffer, "Span", GUICtrlSendMsg($hWnd, $MCM_GETMONTHRANGE, $bPartial, DllStructGetPtr($tBuffer)))
  332. EndIf
  333. Return $tBuffer
  334. EndFunc ;==>_GUICtrlMonthCal_GetMonthRange
  335. ; #FUNCTION# ====================================================================================================================
  336. ; Author ........: Paul Campbell (PaulIA)
  337. ; Modified.......:
  338. ; ===============================================================================================================================
  339. Func _GUICtrlMonthCal_GetMonthRangeMax($hWnd, $bPartial = False)
  340. Local $tBuffer = _GUICtrlMonthCal_GetMonthRange($hWnd, $bPartial)
  341. Local $tRange = DllStructCreate($tagSYSTEMTIME)
  342. DllStructSetData($tRange, "Year", DllStructGetData($tBuffer, "MaxYear"))
  343. DllStructSetData($tRange, "Month", DllStructGetData($tBuffer, "MaxMonth"))
  344. DllStructSetData($tRange, "DOW", DllStructGetData($tBuffer, "MaxDOW"))
  345. DllStructSetData($tRange, "Day", DllStructGetData($tBuffer, "MaxDay"))
  346. Return $tRange
  347. EndFunc ;==>_GUICtrlMonthCal_GetMonthRangeMax
  348. ; #FUNCTION# ====================================================================================================================
  349. ; Author ........: Paul Campbell (PaulIA)
  350. ; Modified.......:
  351. ; ===============================================================================================================================
  352. Func _GUICtrlMonthCal_GetMonthRangeMaxStr($hWnd, $sFormat = "%02d/%02d/%04d")
  353. Local $tBuffer = _GUICtrlMonthCal_GetMonthRangeMax($hWnd)
  354. Return StringFormat($sFormat, DllStructGetData($tBuffer, "Month"), DllStructGetData($tBuffer, "Day"), DllStructGetData($tBuffer, "Year"))
  355. EndFunc ;==>_GUICtrlMonthCal_GetMonthRangeMaxStr
  356. ; #FUNCTION# ====================================================================================================================
  357. ; Author ........: Paul Campbell (PaulIA)
  358. ; Modified.......:
  359. ; ===============================================================================================================================
  360. Func _GUICtrlMonthCal_GetMonthRangeMin($hWnd, $bPartial = False)
  361. Local $tBuffer = _GUICtrlMonthCal_GetMonthRange($hWnd, $bPartial)
  362. Local $tRange = DllStructCreate($tagSYSTEMTIME)
  363. DllStructSetData($tRange, "Year", DllStructGetData($tBuffer, "MinYear"))
  364. DllStructSetData($tRange, "Month", DllStructGetData($tBuffer, "MinMonth"))
  365. DllStructSetData($tRange, "DOW", DllStructGetData($tBuffer, "MinDOW"))
  366. DllStructSetData($tRange, "Day", DllStructGetData($tBuffer, "MinDay"))
  367. Return $tRange
  368. EndFunc ;==>_GUICtrlMonthCal_GetMonthRangeMin
  369. ; #FUNCTION# ====================================================================================================================
  370. ; Author ........: Paul Campbell (PaulIA)
  371. ; Modified.......:
  372. ; ===============================================================================================================================
  373. Func _GUICtrlMonthCal_GetMonthRangeMinStr($hWnd, $sFormat = "%02d/%02d/%04d")
  374. Local $tBuffer = _GUICtrlMonthCal_GetMonthRangeMin($hWnd)
  375. Return StringFormat($sFormat, DllStructGetData($tBuffer, "Month"), DllStructGetData($tBuffer, "Day"), DllStructGetData($tBuffer, "Year"))
  376. EndFunc ;==>_GUICtrlMonthCal_GetMonthRangeMinStr
  377. ; #FUNCTION# ====================================================================================================================
  378. ; Author ........: Paul Campbell (PaulIA)
  379. ; Modified.......:
  380. ; ===============================================================================================================================
  381. Func _GUICtrlMonthCal_GetMonthRangeSpan($hWnd, $bPartial = False)
  382. Local $tBuffer = _GUICtrlMonthCal_GetMonthRange($hWnd, $bPartial)
  383. Return DllStructGetData($tBuffer, "Span")
  384. EndFunc ;==>_GUICtrlMonthCal_GetMonthRangeSpan
  385. ; #FUNCTION# ====================================================================================================================
  386. ; Author ........: Paul Campbell (PaulIA)
  387. ; Modified.......: Gary Frost (gafrost)
  388. ; ===============================================================================================================================
  389. Func _GUICtrlMonthCal_GetRange($hWnd)
  390. Local $iRet
  391. Local $tBuffer = DllStructCreate($tagMCRANGE)
  392. If IsHWnd($hWnd) Then
  393. If _WinAPI_InProcess($hWnd, $__g_hMCLastWnd) Then
  394. $iRet = _SendMessage($hWnd, $MCM_GETRANGE, 0, $tBuffer, 0, "wparam", "struct*")
  395. Else
  396. Local $iBuffer = DllStructGetSize($tBuffer)
  397. Local $tMemMap
  398. Local $pMemory = _MemInit($hWnd, $iBuffer, $tMemMap)
  399. $iRet = _SendMessage($hWnd, $MCM_GETRANGE, 0, $pMemory, 0, "wparam", "ptr")
  400. _MemRead($tMemMap, $pMemory, $tBuffer, $iBuffer)
  401. _MemFree($tMemMap)
  402. EndIf
  403. Else
  404. $iRet = GUICtrlSendMsg($hWnd, $MCM_GETRANGE, 0, DllStructGetPtr($tBuffer))
  405. EndIf
  406. DllStructSetData($tBuffer, "MinSet", BitAND($iRet, $GDTR_MIN) <> 0)
  407. DllStructSetData($tBuffer, "MaxSet", BitAND($iRet, $GDTR_MAX) <> 0)
  408. Return $tBuffer
  409. EndFunc ;==>_GUICtrlMonthCal_GetRange
  410. ; #FUNCTION# ====================================================================================================================
  411. ; Author ........: Paul Campbell (PaulIA)
  412. ; Modified.......:
  413. ; ===============================================================================================================================
  414. Func _GUICtrlMonthCal_GetRangeMax($hWnd)
  415. Local $tBuffer = _GUICtrlMonthCal_GetRange($hWnd)
  416. Local $tRange = DllStructCreate($tagSYSTEMTIME)
  417. DllStructSetData($tRange, "Year", DllStructGetData($tBuffer, "MaxYear"))
  418. DllStructSetData($tRange, "Month", DllStructGetData($tBuffer, "MaxMonth"))
  419. DllStructSetData($tRange, "DOW", DllStructGetData($tBuffer, "MaxDOW"))
  420. DllStructSetData($tRange, "Day", DllStructGetData($tBuffer, "MaxDay"))
  421. Return $tRange
  422. EndFunc ;==>_GUICtrlMonthCal_GetRangeMax
  423. ; #FUNCTION# ====================================================================================================================
  424. ; Author ........: Paul Campbell (PaulIA)
  425. ; Modified.......:
  426. ; ===============================================================================================================================
  427. Func _GUICtrlMonthCal_GetRangeMaxStr($hWnd, $sFormat = "%02d/%02d/%04d")
  428. Local $tBuffer = _GUICtrlMonthCal_GetRangeMax($hWnd)
  429. Return StringFormat($sFormat, DllStructGetData($tBuffer, "Month"), DllStructGetData($tBuffer, "Day"), DllStructGetData($tBuffer, "Year"))
  430. EndFunc ;==>_GUICtrlMonthCal_GetRangeMaxStr
  431. ; #FUNCTION# ====================================================================================================================
  432. ; Author ........: Paul Campbell (PaulIA)
  433. ; Modified.......:
  434. ; ===============================================================================================================================
  435. Func _GUICtrlMonthCal_GetRangeMin($hWnd)
  436. Local $tBuffer = _GUICtrlMonthCal_GetRange($hWnd)
  437. Local $tRange = DllStructCreate($tagSYSTEMTIME)
  438. DllStructSetData($tRange, "Year", DllStructGetData($tBuffer, "MinYear"))
  439. DllStructSetData($tRange, "Month", DllStructGetData($tBuffer, "MinMonth"))
  440. DllStructSetData($tRange, "DOW", DllStructGetData($tBuffer, "MinDOW"))
  441. DllStructSetData($tRange, "Day", DllStructGetData($tBuffer, "MinDay"))
  442. Return $tRange
  443. EndFunc ;==>_GUICtrlMonthCal_GetRangeMin
  444. ; #FUNCTION# ====================================================================================================================
  445. ; Author ........: Paul Campbell (PaulIA)
  446. ; Modified.......:
  447. ; ===============================================================================================================================
  448. Func _GUICtrlMonthCal_GetRangeMinStr($hWnd, $sFormat = "%02d/%02d/%04d")
  449. Local $tBuffer = _GUICtrlMonthCal_GetRangeMin($hWnd)
  450. Return StringFormat($sFormat, DllStructGetData($tBuffer, "Month"), DllStructGetData($tBuffer, "Day"), DllStructGetData($tBuffer, "Year"))
  451. EndFunc ;==>_GUICtrlMonthCal_GetRangeMinStr
  452. ; #FUNCTION# ====================================================================================================================
  453. ; Author ........: Paul Campbell (PaulIA)
  454. ; Modified.......: Gary Frost (gafrost)
  455. ; ===============================================================================================================================
  456. Func _GUICtrlMonthCal_GetSelRange($hWnd)
  457. Local $iRet
  458. Local $tBuffer = DllStructCreate($tagMCSELRANGE)
  459. If IsHWnd($hWnd) Then
  460. If _WinAPI_InProcess($hWnd, $__g_hMCLastWnd) Then
  461. $iRet = _SendMessage($hWnd, $MCM_GETSELRANGE, 0, $tBuffer, 0, "wparam", "ptr")
  462. Else
  463. Local $iBuffer = DllStructGetSize($tBuffer)
  464. Local $tMemMap
  465. Local $pMemory = _MemInit($hWnd, $iBuffer, $tMemMap)
  466. $iRet = _SendMessage($hWnd, $MCM_GETSELRANGE, 0, $pMemory, 0, "wparam", "ptr")
  467. _MemRead($tMemMap, $pMemory, $tBuffer, $iBuffer)
  468. _MemFree($tMemMap)
  469. EndIf
  470. Else
  471. $iRet = GUICtrlSendMsg($hWnd, $MCM_GETSELRANGE, 0, DllStructGetPtr($tBuffer))
  472. EndIf
  473. Return SetError($iRet = 0, 0, $tBuffer)
  474. EndFunc ;==>_GUICtrlMonthCal_GetSelRange
  475. ; #FUNCTION# ====================================================================================================================
  476. ; Author ........: Paul Campbell (PaulIA)
  477. ; Modified.......:
  478. ; ===============================================================================================================================
  479. Func _GUICtrlMonthCal_GetSelRangeMax($hWnd)
  480. Local $tBuffer = _GUICtrlMonthCal_GetSelRange($hWnd)
  481. Local $tRange = DllStructCreate($tagSYSTEMTIME)
  482. DllStructSetData($tRange, "Year", DllStructGetData($tBuffer, "MaxYear"))
  483. DllStructSetData($tRange, "Month", DllStructGetData($tBuffer, "MaxMonth"))
  484. DllStructSetData($tRange, "DOW", DllStructGetData($tBuffer, "MaxDOW"))
  485. DllStructSetData($tRange, "Day", DllStructGetData($tBuffer, "MaxDay"))
  486. Return $tRange
  487. EndFunc ;==>_GUICtrlMonthCal_GetSelRangeMax
  488. ; #FUNCTION# ====================================================================================================================
  489. ; Author ........: Paul Campbell (PaulIA)
  490. ; Modified.......:
  491. ; ===============================================================================================================================
  492. Func _GUICtrlMonthCal_GetSelRangeMaxStr($hWnd, $sFormat = "%02d/%02d/%04d")
  493. Local $tBuffer = _GUICtrlMonthCal_GetSelRangeMax($hWnd)
  494. Return StringFormat($sFormat, DllStructGetData($tBuffer, "Month"), DllStructGetData($tBuffer, "Day"), DllStructGetData($tBuffer, "Year"))
  495. EndFunc ;==>_GUICtrlMonthCal_GetSelRangeMaxStr
  496. ; #FUNCTION# ====================================================================================================================
  497. ; Author ........: Paul Campbell (PaulIA)
  498. ; Modified.......:
  499. ; ===============================================================================================================================
  500. Func _GUICtrlMonthCal_GetSelRangeMin($hWnd)
  501. Local $tBuffer = _GUICtrlMonthCal_GetSelRange($hWnd)
  502. Local $tRange = DllStructCreate($tagSYSTEMTIME)
  503. DllStructSetData($tRange, "Year", DllStructGetData($tBuffer, "MinYear"))
  504. DllStructSetData($tRange, "Month", DllStructGetData($tBuffer, "MinMonth"))
  505. DllStructSetData($tRange, "DOW", DllStructGetData($tBuffer, "MinDOW"))
  506. DllStructSetData($tRange, "Day", DllStructGetData($tBuffer, "MinDay"))
  507. Return $tRange
  508. EndFunc ;==>_GUICtrlMonthCal_GetSelRangeMin
  509. ; #FUNCTION# ====================================================================================================================
  510. ; Author ........: Paul Campbell (PaulIA)
  511. ; Modified.......:
  512. ; ===============================================================================================================================
  513. Func _GUICtrlMonthCal_GetSelRangeMinStr($hWnd, $sFormat = "%02d/%02d/%04d")
  514. Local $tBuffer = _GUICtrlMonthCal_GetSelRangeMin($hWnd)
  515. Return StringFormat($sFormat, DllStructGetData($tBuffer, "Month"), DllStructGetData($tBuffer, "Day"), DllStructGetData($tBuffer, "Year"))
  516. EndFunc ;==>_GUICtrlMonthCal_GetSelRangeMinStr
  517. ; #FUNCTION# ====================================================================================================================
  518. ; Author ........: Paul Campbell (PaulIA)
  519. ; Modified.......: Gary Frost (gafrost)
  520. ; ===============================================================================================================================
  521. Func _GUICtrlMonthCal_GetToday($hWnd)
  522. Local $iRet
  523. Local $tBuffer = DllStructCreate($tagSYSTEMTIME)
  524. If IsHWnd($hWnd) Then
  525. If _WinAPI_InProcess($hWnd, $__g_hMCLastWnd) Then
  526. $iRet = _SendMessage($hWnd, $MCM_GETTODAY, 0, $tBuffer, 0, "wparam", "ptr") <> 0
  527. Else
  528. Local $iBuffer = DllStructGetSize($tBuffer)
  529. Local $tMemMap
  530. Local $pMemory = _MemInit($hWnd, $iBuffer, $tMemMap)
  531. $iRet = _SendMessage($hWnd, $MCM_GETTODAY, 0, $pMemory, 0, "wparam", "ptr") <> 0
  532. _MemRead($tMemMap, $pMemory, $tBuffer, $iBuffer)
  533. _MemFree($tMemMap)
  534. EndIf
  535. Else
  536. $iRet = GUICtrlSendMsg($hWnd, $MCM_GETTODAY, 0, DllStructGetPtr($tBuffer)) <> 0
  537. EndIf
  538. Return SetError($iRet = 0, 0, $tBuffer)
  539. EndFunc ;==>_GUICtrlMonthCal_GetToday
  540. ; #FUNCTION# ====================================================================================================================
  541. ; Author ........: Paul Campbell (PaulIA)
  542. ; Modified.......:
  543. ; ===============================================================================================================================
  544. Func _GUICtrlMonthCal_GetTodayStr($hWnd, $sFormat = "%02d/%02d/%04d")
  545. Local $tBuffer = _GUICtrlMonthCal_GetToday($hWnd)
  546. Return StringFormat($sFormat, DllStructGetData($tBuffer, "Month"), DllStructGetData($tBuffer, "Day"), DllStructGetData($tBuffer, "Year"))
  547. EndFunc ;==>_GUICtrlMonthCal_GetTodayStr
  548. ; #FUNCTION# ====================================================================================================================
  549. ; Author ........: Paul Campbell (PaulIA)
  550. ; Modified.......: Gary Frost (gafrost)
  551. ; ===============================================================================================================================
  552. Func _GUICtrlMonthCal_GetUnicodeFormat($hWnd)
  553. If IsHWnd($hWnd) Then
  554. Return _SendMessage($hWnd, $MCM_GETUNICODEFORMAT) <> 0
  555. Else
  556. Return GUICtrlSendMsg($hWnd, $MCM_GETUNICODEFORMAT, 0, 0) <> 0
  557. EndIf
  558. EndFunc ;==>_GUICtrlMonthCal_GetUnicodeFormat
  559. ; #FUNCTION# ====================================================================================================================
  560. ; Author ........: Paul Campbell (PaulIA)
  561. ; Modified.......: Gary Frost (gafrost)
  562. ; ===============================================================================================================================
  563. Func _GUICtrlMonthCal_HitTest($hWnd, $iX, $iY)
  564. Local $tTest = DllStructCreate($tagMCHITTESTINFO)
  565. Local $iTest = DllStructGetSize($tTest)
  566. DllStructSetData($tTest, "Size", $iTest)
  567. DllStructSetData($tTest, "X", $iX)
  568. DllStructSetData($tTest, "Y", $iY)
  569. If IsHWnd($hWnd) Then
  570. If _WinAPI_InProcess($hWnd, $__g_hMCLastWnd) Then
  571. _SendMessage($hWnd, $MCM_HITTEST, 0, $tTest, 0, "wparam", "struct*")
  572. Else
  573. Local $tMemMap
  574. Local $pMemory = _MemInit($hWnd, $iTest, $tMemMap)
  575. _SendMessage($hWnd, $MCM_HITTEST, 0, $pMemory, 0, "wparam", "ptr")
  576. _MemRead($tMemMap, $pMemory, $tTest, $iTest)
  577. _MemFree($tMemMap)
  578. EndIf
  579. Else
  580. GUICtrlSendMsg($hWnd, $MCM_HITTEST, 0, DllStructGetPtr($tTest))
  581. EndIf
  582. Return $tTest
  583. EndFunc ;==>_GUICtrlMonthCal_HitTest
  584. ; #INTERNAL_USE_ONLY# ===========================================================================================================
  585. ; Name...........: __GUICtrlMonthCal_Resize
  586. ; Description ...: Adjusts the control size so that it is fully shown
  587. ; Syntax.........: __GUICtrlMonthCal_Resize ( $hWnd [, $iX = -1 [, $iY = -1]] )
  588. ; Parameters ....: $hWnd - Handle to control
  589. ; $iX - Left position of calendar. If -1, the current position will be used
  590. ; $iY - Top position of calendar. If -1, the current position will be used
  591. ; Return values .: None
  592. ; Author ........: Paul Campbell (PaulIA)
  593. ; Modified.......: Gary Frost
  594. ; Remarks .......: This function is called internally by _GUICtrlMonthCal_Create and should not normally be called by the end user.
  595. ; Related .......:
  596. ; Link ..........:
  597. ; Example .......:
  598. ; ===============================================================================================================================
  599. Func __GUICtrlMonthCal_Resize($hWnd, $iX = -1, $iY = -1)
  600. Local $iN = _GUICtrlMonthCal_GetMaxTodayWidth($hWnd)
  601. Local $iH = _GUICtrlMonthCal_GetMinReqHeight($hWnd)
  602. Local $iW = _GUICtrlMonthCal_GetMinReqWidth($hWnd)
  603. If $iN > $iW Then $iW = $iN
  604. If ($iX = -1) Or ($iY = -1) Then
  605. Local $tRECT = _WinAPI_GetWindowRect($hWnd)
  606. If $iX = -1 Then $iX = DllStructGetData($tRECT, "Left")
  607. If $iY = -1 Then $iY = DllStructGetData($tRECT, "Top")
  608. EndIf
  609. ;_WinAPI_SetWindowPos($hWnd, 0, $iX, $iY, $iX + $iW, $iY + $iH, $__MONTHCALCONSTANT_SWP_NOZORDER)
  610. _WinAPI_SetWindowPos($hWnd, 0, $iX, $iY, $iW, $iH, $__MONTHCALCONSTANT_SWP_NOZORDER)
  611. EndFunc ;==>__GUICtrlMonthCal_Resize
  612. ; #FUNCTION# ====================================================================================================================
  613. ; Author ........: Gary Frost
  614. ; Modified.......:
  615. ; ===============================================================================================================================
  616. Func _GUICtrlMonthCal_SetCalendarBorder($hWnd, $iBorderSize = 4, $bSetBorder = True)
  617. If IsHWnd($hWnd) Then
  618. _SendMessage($hWnd, $MCM_SETCALENDARBORDER, $bSetBorder, $iBorderSize)
  619. Else
  620. GUICtrlSendMsg($hWnd, $MCM_SETCALENDARBORDER, $bSetBorder, $iBorderSize)
  621. EndIf
  622. EndFunc ;==>_GUICtrlMonthCal_SetCalendarBorder
  623. ; #FUNCTION# ====================================================================================================================
  624. ; Author ........: Paul Campbell (PaulIA)
  625. ; Modified.......: Gary Frost (gafrost)
  626. ; ===============================================================================================================================
  627. Func _GUICtrlMonthCal_SetColor($hWnd, $iIndex, $iColor)
  628. If IsHWnd($hWnd) Then
  629. Return _SendMessage($hWnd, $MCM_SETCOLOR, $iIndex, $iColor)
  630. Else
  631. Return GUICtrlSendMsg($hWnd, $MCM_SETCOLOR, $iIndex, $iColor)
  632. EndIf
  633. EndFunc ;==>_GUICtrlMonthCal_SetColor
  634. ; #FUNCTION# ====================================================================================================================
  635. ; Author ........: Paul Campbell (PaulIA)
  636. ; Modified.......: Gary Frost (gafrost)
  637. ; ===============================================================================================================================
  638. Func _GUICtrlMonthCal_SetCurSel($hWnd, $iYear, $iMonth, $iDay)
  639. Local $iRet
  640. Local $tBuffer = DllStructCreate($tagSYSTEMTIME)
  641. DllStructSetData($tBuffer, "Month", $iMonth)
  642. DllStructSetData($tBuffer, "Day", $iDay)
  643. DllStructSetData($tBuffer, "Year", $iYear)
  644. If IsHWnd($hWnd) Then
  645. If _WinAPI_InProcess($hWnd, $__g_hMCLastWnd) Then
  646. $iRet = _SendMessage($hWnd, $MCM_SETCURSEL, 0, $tBuffer, 0, "wparam", "ptr")
  647. Else
  648. Local $iBuffer = DllStructGetSize($tBuffer)
  649. Local $tMemMap
  650. Local $pMemory = _MemInit($hWnd, $iBuffer, $tMemMap)
  651. _MemWrite($tMemMap, $tBuffer)
  652. $iRet = _SendMessage($hWnd, $MCM_SETCURSEL, 0, $pMemory, 0, "wparam", "ptr")
  653. _MemFree($tMemMap)
  654. EndIf
  655. Else
  656. $iRet = GUICtrlSendMsg($hWnd, $MCM_SETCURSEL, 0, DllStructGetPtr($tBuffer))
  657. EndIf
  658. Return $iRet <> 0
  659. EndFunc ;==>_GUICtrlMonthCal_SetCurSel
  660. ; #FUNCTION# ====================================================================================================================
  661. ; Author ........: Paul Campbell (PaulIA)
  662. ; Modified.......: Gary Frost (gafrost)
  663. ; ===============================================================================================================================
  664. Func _GUICtrlMonthCal_SetDayState($hWnd, $aMasks)
  665. Local $iRet
  666. Local $iMasks = _GUICtrlMonthCal_GetMonthRangeSpan($hWnd, True)
  667. Local $tBuffer = DllStructCreate("int;int;int")
  668. For $iI = 0 To $iMasks - 1
  669. DllStructSetData($tBuffer, $iI + 1, $aMasks[$iI])
  670. Next
  671. If IsHWnd($hWnd) Then
  672. If _WinAPI_InProcess($hWnd, $__g_hMCLastWnd) Then
  673. $iRet = _SendMessage($hWnd, $MCM_SETDAYSTATE, $iMasks, $tBuffer, 0, "wparam", "struct*")
  674. Else
  675. Local $iBuffer = DllStructGetSize($tBuffer)
  676. Local $tMemMap
  677. Local $pMemory = _MemInit($hWnd, $iBuffer, $tMemMap)
  678. _MemWrite($tMemMap, $tBuffer)
  679. $iRet = _SendMessage($hWnd, $MCM_SETDAYSTATE, $iMasks, $pMemory, 0, "wparam", "ptr")
  680. _MemFree($tMemMap)
  681. EndIf
  682. Else
  683. $iRet = GUICtrlSendMsg($hWnd, $MCM_SETDAYSTATE, $iMasks, DllStructGetPtr($tBuffer))
  684. EndIf
  685. Return $iRet <> 0
  686. EndFunc ;==>_GUICtrlMonthCal_SetDayState
  687. ; #FUNCTION# ====================================================================================================================
  688. ; Author ........: Gary Frost (gafrost)
  689. ; Modified.......:
  690. ; ===============================================================================================================================
  691. Func _GUICtrlMonthCal_SetFirstDOW($hWnd, $sDay)
  692. Local $i_Day
  693. If $sDay >= 0 Or $sDay <= 6 Then
  694. $i_Day = $sDay
  695. ElseIf StringInStr("MONDAY TUESDAY WEDNESDAY THURSDAY FRIDAY SATURDAY SUNDAY", $sDay) Then
  696. Switch StringUpper($sDay)
  697. Case "MONDAY"
  698. $i_Day = 0
  699. Case "TUESDAY"
  700. $i_Day = 1
  701. Case "WEDNESDAY"
  702. $i_Day = 2
  703. Case "THURSDAY"
  704. $i_Day = 3
  705. Case "FRIDAY"
  706. $i_Day = 4
  707. Case "SATURDAY"
  708. $i_Day = 5
  709. Case "SUNDAY"
  710. $i_Day = 6
  711. EndSwitch
  712. Else
  713. Return SetError(-1, -1, -1)
  714. EndIf
  715. If IsHWnd($hWnd) Then
  716. Return _SendMessage($hWnd, $MCM_SETFIRSTDAYOFWEEK, 0, $i_Day)
  717. Else
  718. Return GUICtrlSendMsg($hWnd, $MCM_SETFIRSTDAYOFWEEK, 0, $i_Day)
  719. EndIf
  720. EndFunc ;==>_GUICtrlMonthCal_SetFirstDOW
  721. ; #FUNCTION# ====================================================================================================================
  722. ; Author ........: Gary Frost (gafrost)
  723. ; Modified.......:
  724. ; ===============================================================================================================================
  725. Func _GUICtrlMonthCal_SetMaxSelCount($hWnd, $iMaxSel)
  726. If IsHWnd($hWnd) Then
  727. Return _SendMessage($hWnd, $MCM_SETMAXSELCOUNT, $iMaxSel) <> 0
  728. Else
  729. Return GUICtrlSendMsg($hWnd, $MCM_SETMAXSELCOUNT, $iMaxSel, 0) <> 0
  730. EndIf
  731. EndFunc ;==>_GUICtrlMonthCal_SetMaxSelCount
  732. ; #FUNCTION# ====================================================================================================================
  733. ; Author ........: Gary Frost (gafrost)
  734. ; Modified.......:
  735. ; ===============================================================================================================================
  736. Func _GUICtrlMonthCal_SetMonthDelta($hWnd, $iDelta)
  737. If IsHWnd($hWnd) Then
  738. Return _SendMessage($hWnd, $MCM_SETMONTHDELTA, $iDelta)
  739. Else
  740. Return GUICtrlSendMsg($hWnd, $MCM_SETMONTHDELTA, $iDelta, 0)
  741. EndIf
  742. EndFunc ;==>_GUICtrlMonthCal_SetMonthDelta
  743. ; #FUNCTION# ====================================================================================================================
  744. ; Author ........: Paul Campbell (PaulIA)
  745. ; Modified.......: Gary Frost (gafrost)
  746. ; ===============================================================================================================================
  747. Func _GUICtrlMonthCal_SetRange($hWnd, $iMinYear, $iMinMonth, $iMinDay, $iMaxYear, $iMaxMonth, $iMaxDay)
  748. Local $iRet
  749. Local $tRange = DllStructCreate($tagMCRANGE)
  750. Local $iFlags = BitOR($GDTR_MIN, $GDTR_MAX)
  751. DllStructSetData($tRange, "MinYear", $iMinYear)
  752. DllStructSetData($tRange, "MinMonth", $iMinMonth)
  753. DllStructSetData($tRange, "MinDay", $iMinDay)
  754. DllStructSetData($tRange, "MaxYear", $iMaxYear)
  755. DllStructSetData($tRange, "MaxMonth", $iMaxMonth)
  756. DllStructSetData($tRange, "MaxDay", $iMaxDay)
  757. If IsHWnd($hWnd) Then
  758. If _WinAPI_InProcess($hWnd, $__g_hMCLastWnd) Then
  759. $iRet = _SendMessage($hWnd, $MCM_SETRANGE, $iFlags, $tRange, 0, "wparam", "ptr")
  760. Else
  761. Local $iRange = DllStructGetSize($tRange)
  762. Local $tMemMap
  763. Local $pMemory = _MemInit($hWnd, $iRange, $tMemMap)
  764. _MemWrite($tMemMap, $tRange)
  765. $iRet = _SendMessage($hWnd, $MCM_SETRANGE, $iFlags, $pMemory, 0, "wparam", "ptr")
  766. _MemFree($tMemMap)
  767. EndIf
  768. Else
  769. $iRet = GUICtrlSendMsg($hWnd, $MCM_SETRANGE, $iFlags, DllStructGetPtr($tRange))
  770. EndIf
  771. Return $iRet <> 0
  772. EndFunc ;==>_GUICtrlMonthCal_SetRange
  773. ; #FUNCTION# ====================================================================================================================
  774. ; Author ........: Paul Campbell (PaulIA)
  775. ; Modified.......: Gary Frost (gafrost)
  776. ; ===============================================================================================================================
  777. Func _GUICtrlMonthCal_SetSelRange($hWnd, $iMinYear, $iMinMonth, $iMinDay, $iMaxYear, $iMaxMonth, $iMaxDay)
  778. Local $tBuffer = DllStructCreate($tagMCRANGE)
  779. DllStructSetData($tBuffer, "MinYear", $iMinYear)
  780. DllStructSetData($tBuffer, "MinMonth", $iMinMonth)
  781. DllStructSetData($tBuffer, "MinDay", $iMinDay)
  782. DllStructSetData($tBuffer, "MaxYear", $iMaxYear)
  783. DllStructSetData($tBuffer, "MaxMonth", $iMaxMonth)
  784. DllStructSetData($tBuffer, "MaxDay", $iMaxDay)
  785. Local $iRet
  786. If IsHWnd($hWnd) Then
  787. If _WinAPI_InProcess($hWnd, $__g_hMCLastWnd) Then
  788. $iRet = _SendMessage($hWnd, $MCM_SETSELRANGE, 0, $tBuffer, 0, "wparam", "struct*")
  789. Else
  790. Local $iBuffer = DllStructGetSize($tBuffer)
  791. Local $tMemMap
  792. Local $pMemory = _MemInit($hWnd, $iBuffer, $tMemMap)
  793. _MemWrite($tMemMap, $tBuffer)
  794. $iRet = _SendMessage($hWnd, $MCM_SETSELRANGE, 0, $pMemory, 0, "wparam", "ptr")
  795. _MemFree($tMemMap)
  796. EndIf
  797. Else
  798. $iRet = GUICtrlSendMsg($hWnd, $MCM_SETSELRANGE, 0, DllStructGetPtr($tBuffer))
  799. EndIf
  800. Return $iRet <> 0
  801. EndFunc ;==>_GUICtrlMonthCal_SetSelRange
  802. ; #FUNCTION# ====================================================================================================================
  803. ; Author ........: Paul Campbell (PaulIA)
  804. ; Modified.......: Gary Frost (gafrost)
  805. ; ===============================================================================================================================
  806. Func _GUICtrlMonthCal_SetToday($hWnd, $iYear, $iMonth, $iDay)
  807. Local $tBuffer = DllStructCreate($tagSYSTEMTIME)
  808. DllStructSetData($tBuffer, "Month", $iMonth)
  809. DllStructSetData($tBuffer, "Day", $iDay)
  810. DllStructSetData($tBuffer, "Year", $iYear)
  811. If IsHWnd($hWnd) Then
  812. If _WinAPI_InProcess($hWnd, $__g_hMCLastWnd) Then
  813. _SendMessage($hWnd, $MCM_SETTODAY, 0, $tBuffer, 0, "wparam", "struct*")
  814. Else
  815. Local $iBuffer = DllStructGetSize($tBuffer)
  816. Local $tMemMap
  817. Local $pMemory = _MemInit($hWnd, $iBuffer, $tMemMap)
  818. _MemWrite($tMemMap, $tBuffer)
  819. _SendMessage($hWnd, $MCM_SETTODAY, 0, $pMemory, 0, "wparam", "ptr")
  820. _MemFree($tMemMap)
  821. EndIf
  822. Else
  823. GUICtrlSendMsg($hWnd, $MCM_SETTODAY, 0, DllStructGetPtr($tBuffer))
  824. EndIf
  825. EndFunc ;==>_GUICtrlMonthCal_SetToday
  826. ; #FUNCTION# ====================================================================================================================
  827. ; Author ........: Paul Campbell (PaulIA)
  828. ; Modified.......: Gary Frost (gafrost)
  829. ; ===============================================================================================================================
  830. Func _GUICtrlMonthCal_SetUnicodeFormat($hWnd, $bUnicode = False)
  831. If IsHWnd($hWnd) Then
  832. Return _SendMessage($hWnd, $MCM_SETUNICODEFORMAT, $bUnicode) <> 0
  833. Else
  834. Return GUICtrlSendMsg($hWnd, $MCM_SETUNICODEFORMAT, $bUnicode, 0) <> 0
  835. EndIf
  836. EndFunc ;==>_GUICtrlMonthCal_SetUnicodeFormat