wipnav
asked on
Handling TDateTimePicker events
Hi,
How can I know when the user presses the escape key, or clicks outside of the control, to close a TDateTimePicker?
I've tried using Keydown to trap the escape key, but can't get it to work.
Regards,
Bill
How can I know when the user presses the escape key, or clicks outside of the control, to close a TDateTimePicker?
I've tried using Keydown to trap the escape key, but can't get it to work.
Regards,
Bill
do you want to know if he picked the date? or just if the user has canceled?
ASKER
I need to know if the user cancelled, either because he pressed escape or clicked somewhere else.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
So do like this
var
PreviousDateTime: TDateTime;
procedure TForm1.DateTimePicker1Clos eUp(Sender : TObject);
begin
if DateTimePicker1.DateTime = PreviousDateTime then
begin
Memo1.lines.Add('cancelled '); // or whatever
end;
end;
procedure TForm1.DateTimePicker1Drop Down(Sende r: TObject);
begin
PreviousDateTime := DateTimePicker1.DateTime;
end;
var
PreviousDateTime: TDateTime;
procedure TForm1.DateTimePicker1Clos
begin
if DateTimePicker1.DateTime = PreviousDateTime then
begin
Memo1.lines.Add('cancelled
end;
end;
procedure TForm1.DateTimePicker1Drop
begin
PreviousDateTime := DateTimePicker1.DateTime;
end;
ASKER
Balshe,
I was thinking of some sort of event driven solution, but I think I can use what you suggest.
Thanks,
Bill
I was thinking of some sort of event driven solution, but I think I can use what you suggest.
Thanks,
Bill
Balshe's solution works only once.
Strange You accept it.
Strange You accept it.
ASKER
It's the concept of simply checking if the date changed, not the actual implementation, that I accepted as a solution.
procedure TForm1.DateTimePicker1Clos
begin
// do whatever
end;