Jump to content

GUICtrlCreateDate() - is it possible to predefine a set or a range of dates, that are *SELECTABLE*?


Recommended Posts

Hello,

 

due to the help file on GUICtrlCreateDate() there seems no direct possibility to preset a range of SELECTABLE dates, like it is pretty common e.g. in online booking web pages: There the dates no more available are greyed out and cannot be selected.

 

So my approach would be to check after user date selection, and in case the date should not be selectable, bring up some message "... is not available." It would be much more intuitive for the user to "gray out" all dates, then to turn available dates to "normal" (selectable), so that just available dates will be selectable.

 

(background: A set of log files, the range / set of available dates isn't reliable predictable: Can be longer to the past, of course never in the future, and not every day must have a LOG file)

 

TIA, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

Link to comment
Share on other sites

Also if its useful (Nine's solution may be better!) - it seems you can use the MCS_MULTISELECT style with a "Month Calendar Control".

I'm not entirely sure which notification GuiGetMessage looks for (presumably MCN_SELCHANGE - I'd need more of a play) - But if GGM is trigger happy, you can always handle WM_NOTIFY and look for MCN_SELCHANGE messages ;).

 

Edit - Ahh sorry misread the original question. It looks like you may be able to make dates bold with this control, but probably not greyed out.

 

#include <guiconstants.au3>

$hGUI = GUICreate("", 404, 404)
$hCal = GUICtrlCreateMonthCal("", 4, 4, 250, 200, $MCS_MULTISELECT)


Local $tagSYSTEMTIME = "align 2; word Year; word Month; word DayOfWeek; " & _
        "word Day; word Hour; word Minute; word Second; word Milliseconds;"

Local $tTimeSel = DllStructCreate("word StartSel[8];word EndSel[8]")
Local $pTimeSel = DllStructGetPtr($tTimeSel)
Local $tSysTime

GUISetState()
While 1
    $iMsg = GUIGetMsg()

    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $hCal
            GUICtrlSendMsg($hCal, $MCM_GETSELRANGE, 0, $pTimeSel)
            $tSysTime = DllStructCreate($tagSYSTEMTIME, $pTimeSel)
            ConsoleWrite(StringFormat("StartSel - Day: %s Month: %s Year: %s", $tSysTime.Day, $tSysTime.Month, $tSysTime.Year) & @CRLF)
            $tSysTime = DllStructCreate($tagSYSTEMTIME, Ptr($pTimeSel + 16))
            ConsoleWrite(StringFormat("EndSel - Day: %s Month: %s Year: %s", $tSysTime.Day, $tSysTime.Month, $tSysTime.Year) & @CRLF)

    EndSwitch

WEnd
Edited by MattyD
Link to comment
Share on other sites

OK FWIW it seems setting limits is possible after all...

#include <guiconstants.au3>

$hGUI = GUICreate("", 400, 400)
$hCal = GUICtrlCreateMonthCal("", -1,-1,-1,-1, BitOR($MCS_MULTISELECT, $MCS_NOTODAY, $MCS_NOTODAYCIRCLE))


Local $tagSYSTEMTIME = "align 2; word Year; word Month; word DayOfWeek; " & _
        "word Day; word Hour; word Minute; word Second; word Milliseconds;"

Local $tTimeSel = DllStructCreate("word StartSel[8];word EndSel[8]")
Local $pTimeSel = DllStructGetPtr($tTimeSel)
Local $tSysTime

GUISetState()

;;;Set Selectable Range ;;;;

;Selectable Start Date - 1st of previous Month
$tSysTime = DllStructCreate($tagSYSTEMTIME, $pTimeSel)
$tSysTime.Day = 1
$tSysTime.Month = Mod(@MON - 1, 12)
$tSysTime.Year = @YEAR

;Selectable End Date - 1st of next Month
$tSysTime = DllStructCreate($tagSYSTEMTIME, Ptr($pTimeSel + 16))
$tSysTime.Day = 1
$tSysTime.Month = Mod(@MON + 1, 12)
$tSysTime.Year = @YEAR

GUICtrlSendMsg($hCal, $MCM_SETRANGE, BitOR($GDTR_MIN, $GDTR_MAX), $pTimeSel)

;;;;;;;;;;;;;;;;;;;;;;;;;;;

;Set Max selectable days
GUICtrlSendMsg($hCal, $MCM_SETMAXSELCOUNT, 10, 0)


While 1
    $iMsg = GUIGetMsg()

    Switch $iMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $hCal
            GUICtrlSendMsg($hCal, $MCM_GETSELRANGE, 0, $pTimeSel)
            $tSysTime = DllStructCreate($tagSYSTEMTIME, $pTimeSel)
            ConsoleWrite(StringFormat("StartSel - Day: %s Month: %s Year: %s", $tSysTime.Day, $tSysTime.Month, $tSysTime.Year) & @CRLF)
            $tSysTime = DllStructCreate($tagSYSTEMTIME, Ptr($pTimeSel + 16))
            ConsoleWrite(StringFormat("EndSel - Day: %s Month: %s Year: %s", $tSysTime.Day, $tSysTime.Month, $tSysTime.Year) & @CRLF)

    EndSwitch

WEnd
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...