Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: TCalendarPicker OnCloseUp


This question is not answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 1 - Last Post: Dec 7, 2016 4:35 AM Last Post By: Lajos Juhasz Threads: [ Previous | Next ]
David Smith

Posts: 7
Registered: 6/15/14
TCalendarPicker OnCloseUp  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 7, 2016 3:22 AM
Hi, hope this is a sensible forum for this type of query, my apologies if it is not.
I was hoping to use the new TCalendarPicker control available in Berlin 10.1 Update 2 in an existing application, replacing an old TDateTimePicker control with the new one. The 'trouble' I am having is with code that checks what date has been selected in the OnCloseUp event.
The date chosen must be an end of month date and we cannot rely upon users (can we ..) to select something so the old TDateTimePicker control used OnCloseUp code such as (where cpStartDate is the control):

if cpStartDate.Date <> EndOfTheMonth(cpStartDate.Date) then
begin
cpStartDate.Date := EndOfTheMonth(cpStartDate.Date);
end;

and this works well.

Trying to replace the old control with the new one and the same OnCloseUp code produces the image at run-time of the value being chosen by the user (say mid-month 15th April) immediately changed to the end of the given month (30th April), but at the end of the close up routine, it (the TCalendarPicker control) then reverts back to the user chosen date (15th April).

Has anyone any thoughts please on why this might be happening? - and many thanks in advance..

David
Lajos Juhasz

Posts: 801
Registered: 3/14/14
Re: TCalendarPicker OnCloseUp  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Dec 7, 2016 4:35 AM   in response to: David Smith in response to: David Smith
David Smith wrote:

Trying to replace the old control with the new one and the same
OnCloseUp code produces the image at run-time of the value being
chosen by the user (say mid-month 15th April) immediately changed to
the end of the given month (30th April), but at the end of the close
up routine, it (the TCalendarPicker control) then reverts back to the
user chosen date (15th April).

Has anyone any thoughts please on why this might be happening? - and
many thanks in advance..

The component design is not perfect. The problem is that
CalendarViewChange will write directly into the FDate field
(TCustomCalendarPicker.CalendarViewChange). I find this design a bit
strange as prior to that OnCloseUp will change the date and trigger the
OnChange event. IMHO this is a bug.

You can make a workaround. Instead of changing the date in the event
you can start a TTimer with a small delay like 100ms and change there
or send a custom message to the form.

A better place to ask this question would be
embarcadero.public.delphi.vcl.components.using. This is a question
about a Delphi component not an API.

Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02