- This topic has 12 replies, 3 voices, and was last updated 4 years, 2 months ago by HeDiBo.
-
AuthorPosts
-
August 11, 2020 at 2:56 pm #69223HeDiBoParticipant
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.
August 11, 2020 at 9:18 pm #69233SupportKeymasterI will think about a best solution soon.
August 12, 2020 at 9:02 am #69236HeDiBoParticipantOn 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.August 12, 2020 at 9:09 am #69237HeDiBoParticipantBy 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.August 12, 2020 at 11:01 am #69238HeDiBoParticipantEven 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.
August 16, 2020 at 6:56 pm #69265SupportKeymasterThe 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?August 16, 2020 at 9:46 pm #69274HeDiBoParticipant<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.
August 19, 2020 at 7:57 pm #69291SupportKeymasterI will think about this ChecksActive property.
VCL has a lot of events implemented, but thre is no special properties for enabling/disabling them…August 19, 2020 at 11:02 pm #69299HeDiBoParticipantVCL 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
August 24, 2020 at 8:24 pm #69335SupportKeymasterI meant that events has not special property for disabling them, usually.
August 24, 2020 at 11:01 pm #69344Stephane SenecalParticipantYou 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 2001August 25, 2020 at 9:35 am #69346HeDiBoParticipantThank 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, 2 months ago by HeDiBo.
September 8, 2020 at 10:11 am #69452HeDiBoParticipantI found an alternative to nilling the event. You can close this topic.
-
AuthorPosts
- The topic ‘AC15.13: TsMonthCalendar should have a function to reload’ is closed to new replies.