BugFix Posted December 22, 2009 Share Posted December 22, 2009 (edited) Hi,at first i've made here an function to create mask for _GUICtrlMonthCal_SetDayState.But now i think, i'ts more easy to give all days in an delimited string and create the mask inside function.I've modified _GUICtrlMonthCal_SetDayState for this. Function name here: __GUICtrlMonthCal_SetDayStateEditNow i've made another modification: You can give the date values as delimited string or as an array. expandcollapse popup#include <GuiConstantsEx.au3> #include <GuiMonthCal.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) GUICreate("Month Calendar Set Day State", 400, 300) Local $hMonthCal = GUICtrlCreateMonthCal("", 4, 4, -1, -1, BitOR($WS_BORDER, $MCS_DAYSTATE), 0x00000000) __GUICtrlMonthCal_SetDayState($hMonthCal, '1,5,6,8,12,22,23,24,30', ',') GUISetState() Sleep(1500) __GUICtrlMonthCal_SetDayState($hMonthCal, '1,2,3,12,13,14,29,30', ',') Sleep(1500) __GUICtrlMonthCal_SetDayState($hMonthCal, '11', ',') Sleep(1500) __GUICtrlMonthCal_SetDayState($hMonthCal, '') ; unset all ; same with array Sleep(1500) Local $a[9] = [1,5,6,8,12,22,23,24,30] __GUICtrlMonthCal_SetDayState($hMonthCal, $a) Sleep(1500) Local $b[8] = [1,2,3,12,13,14,29,30] __GUICtrlMonthCal_SetDayState($hMonthCal, $b) Sleep(1500) Local $c[1] = [11] __GUICtrlMonthCal_SetDayState($hMonthCal, $c) Sleep(1500) Local $d[1] = [''] __GUICtrlMonthCal_SetDayState($hMonthCal, $d) Do Until GUIGetMsg() = $GUI_EVENT_CLOSE ; #FUNCTION# ==================================================================================================================== ; Name...........: __GUICtrlMonthCal_SetDayState ; Description ...: Sets the day states for all months that are currently visible ; Syntax.........: _GUICtrlMonthCal_SetDayState($hWnd, $sDays [, $sDelim = Default]) ; Parameters ....: $hWnd - Handle to control ; $s_a_Days - An delimited string or an array of days, whose state to set, with '' unset all ; $sDelim - Delimiter in $sDays, by default char from Opt('GUIDataSeparatorChar') ; Return values .: Success - True ; Failure - False ; Author ........: Paul Campbell (PaulIA) ; Modified.......: Gary Frost (gafrost), BugFix ; Remarks .......: You must create the calendar control with the $MCS_DAYSTATE style if you want to use this function ; Related .......: ; Link ..........: ; Example .......: Yes ; =============================================================================================================================== Func __GUICtrlMonthCal_SetDayState($hWnd, $s_a_Days, $sDelim = Default) If $Debug_MC Then __UDF_ValidateClassName($hWnd, $__MONTHCALCONSTANT_ClassName) Local $iRet Local $iMasks = _GUICtrlMonthCal_GetMonthRangeSpan($hWnd, True) Local $tBuffer = DllStructCreate("int;int;int") Local $pBuffer = DllStructGetPtr($tBuffer) ;==================================================== my changes Local $aMasks[$iMasks] If $sDelim = Default Then $sDelim = Opt('GUIDataSeparatorChar') If (( Not IsArray($s_a_Days) ) And ($s_a_Days = '') ) Or _ (( IsArray($s_a_Days) ) And ($s_a_Days[0] = '') ) Then $aMasks[1] = '0x0' Else Local $aDays If (Not IsArray($s_a_Days)) Then $aDays = StringSplit($s_a_Days, $sDelim, 2) Else $aDays = $s_a_Days EndIf Local $aHex[8] = [0,0,0,0,0,0,0,0], $pos, $mask = '' For $i = 0 To UBound($aDays) -1 Select Case $aDays[$i] < 5 $pos = 0 Case $aDays[$i] < 9 $pos = 1 Case $aDays[$i] < 13 $pos = 2 Case $aDays[$i] < 17 $pos = 3 Case $aDays[$i] < 21 $pos = 4 Case $aDays[$i] < 25 $pos = 5 Case $aDays[$i] < 29 $pos = 6 Case Else $pos = 7 EndSelect $aDays[$i] -= $pos * 4 $aHex[$pos] += 2 ^ ($aDays[$i]-1) Next For $i = 0 To UBound($aHex) -1 $mask = Hex($aHex[$i], 1) & $mask Next $aMasks[1] = '0x' & $mask EndIf ;==================================================== For $iI = 0 To $iMasks - 1 DllStructSetData($tBuffer, $iI + 1, $aMasks[$iI]) Next If IsHWnd($hWnd) Then If _WinAPI_InProcess($hWnd, $_mc_ghMCLastWnd) Then $iRet = _SendMessage($hWnd, $MCM_SETDAYSTATE, $iMasks, $pBuffer, 0, "wparam", "ptr") Else Local $iBuffer = DllStructGetSize($tBuffer) Local $tMemMap Local $pMemory = _MemInit($hWnd, $iBuffer, $tMemMap) _MemWrite($tMemMap, $pBuffer) $iRet = _SendMessage($hWnd, $MCM_SETDAYSTATE, $iMasks, $pMemory, 0, "wparam", "ptr") _MemFree($tMemMap) EndIf Else $iRet = GUICtrlSendMsg($hWnd, $MCM_SETDAYSTATE, $iMasks, $pBuffer) EndIf Return $iRet <> 0 EndFunc ;==>__GUICtrlMonthCal_SetDayStateWhat you mean? Is it an usefull enhancement? Edited December 22, 2009 by BugFix Best Regards BugFix Link to comment Share on other sites More sharing options...
BugFix Posted February 21, 2010 Author Share Posted February 21, 2010 Two month has gone, but nowhere has an opinion about that? I think it's usefull. But if you have an dissenting opinion, its better as keep still. Best Regards BugFix Link to comment Share on other sites More sharing options...
BugFix Posted December 2, 2010 Author Share Posted December 2, 2010 Sorry, that i come back with this after nearly one year. But now here more than 450 hits and nobody has an opinion? I've no problem with criticism, but silence is uncanny for me. Best Regards BugFix Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 2, 2010 Share Posted December 2, 2010 Opinion: This was the wrong forum for this topic. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
GEOSoft Posted December 2, 2010 Share Posted December 2, 2010 I agree with the penguin. It's the wrong Forum but some people just don't read the forum descriptions. It probably belongs in Example Scripts. If you are trying to get it included in a UDF, there is a set of guidelines posted for doing that. There is also Trac which again has a set of guidelines. Now can we start betting on how much code is going to be added to the UDFs right now? George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now