AC15.13: TsMonthCalendar should have a function to reload

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #69223
    HeDiBo
    Participant

    Because Item 68833 was solved, the optimization was a bit too optimal. In a case were the calendar is part of a form the OnAcceptDate calls may come before the conditions are properly set. So there should be a way to force TsMonthCalendar to evaluate all the dates from that month again.
    I found the call UpdateCalendar, but it also seems to need property CalendarChanged to be True. A simple solutions would be to combine these two in a new public function: ReloadCalendar.

    PS. It took me almost a week to find the cause of my calendar showing wrong disabled dates. Only when I realized that OnAcceptDate was not called anymore I found a solution.

    #69233
    Support
    Keymaster

    I will think about a best solution soon.

    #69236
    HeDiBo
    Participant

    On second thoughts, a better solution would be a published property ChecksActive. That would be True by default, but being published can also be initialized to False. When False, all dates are OK and no calls to OnAcceptDate are done. When set to True, it will call OnAcceptDate for all dates in the current month and keep on working like it is now.
    The benefit of this over a ReloadCalendar procedure would be that it will prevent 30 checks at component load time (a possibly costly operation), that would not lead to anything sensible any way.

    #69237
    HeDiBo
    Participant

    By the way, setting OnAcceptDate to non-nil in code, does not recheck the dates as you would expect.
    I say that, because that would also be a feasible solution: having the OnAcceptDate being set to nil normally and only set it to a checking procedure when you need that. But then checks should be redone at that moment.

    #69238
    HeDiBo
    Participant

    Even if setting OnAcceptDate to non-nil would force a recheck of all month dates, there’s still the need for a RecheckCalendar procedure, in cases where the dates acceptable have changed.

    #69265
    Support
    Keymaster

    The RefreshAcceptedDates procedure will be available in the v15.14
    Behavior of the ChecksActive is not obvious. Do you suggest to enable/disable calling of the OnAcceptDate event by this property?

    #69274
    HeDiBo
    Participant

    <p zoompage-fontsize=”14″>The RefreshAcceptedDates procedure will be available in the v15.14
    Behavior of the ChecksActive is not obvious. Do you suggest to enable/disable calling of the OnAcceptDate event by this property?

    Yes. It gives the best of both worlds: 1. By setting it False at design time, no initial OnAcceptDate events will occur. Then setting it to True, it will do an OnAcceptDate for every day in that month. Leaving it to True, the TsMonthCalendar functions as it is now. But if you want all dates rechecked, set the property to False and to True again.

    #69291
    Support
    Keymaster

    I will think about this ChecksActive property.
    VCL has a lot of events implemented, but thre is no special properties for enabling/disabling them…

    #69299
    HeDiBo
    Participant

    VCL has a lot of events implemented, but thre is no special properties for enabling/disabling them…

    I’m not sure what you mean by that

    #69335
    Support
    Keymaster

    I meant that events has not special property for disabling them, usually.

    #69344
    Stephane Senecal
    Participant

    You could leave the event OnAcceptDate unset at design and set it at runtime when you are ready to process which dates should be available. Just after setting the event, call RefreshAcceptedDates().
    When you need to disable the verification of dates, set OnAcceptDate to nil and set it back to your function when ready with a call to RefreshAcceptedDates().

    Stephane Senecal
    CIS Group
    Delphi programmer since 2001

    #69346
    HeDiBo
    Participant

    Thank you Stephane. I thought of it as an alternative to RefreshAcceptedDates. It would do all you describe, but more elegantly.

    • This reply was modified 4 years, 1 month ago by HeDiBo.
    #69452
    HeDiBo
    Participant

    I found an alternative to nilling the event. You can close this topic.

Viewing 13 posts - 1 through 13 (of 13 total)
  • The topic ‘AC15.13: TsMonthCalendar should have a function to reload’ is closed to new replies.