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
LVL 1
wipnavAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

mokuleCommented:
try to use OnCloseUp event

procedure TForm1.DateTimePicker1CloseUp(Sender: TObject);
begin
  // do whatever
end;
0
BalsheCommented:
do you want to know if he picked the date? or just if the user has canceled?
0
wipnavAuthor Commented:
I need to know if the user cancelled, either because he pressed escape or clicked somewhere else.
0
Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

BalsheCommented:
is this usefull:

 T:TDate;
implementation

{$R *.dfm}


procedure TForm1.FormCreate(Sender: TObject);


begin

  t:=DateTimePicker1.Date;

end;

procedure TForm1.DateTimePicker1CloseUp(Sender: TObject);
begin
  if t=DateTimePicker1.Date then
ShowMessage('User Canceled');
end;

??


0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mokuleCommented:
So do like this

var
    PreviousDateTime: TDateTime;


procedure TForm1.DateTimePicker1CloseUp(Sender: TObject);
begin
  if DateTimePicker1.DateTime = PreviousDateTime then
    begin
    Memo1.lines.Add('cancelled'); // or whatever
    end;
end;

procedure TForm1.DateTimePicker1DropDown(Sender: TObject);
begin
  PreviousDateTime := DateTimePicker1.DateTime;
end;
0
wipnavAuthor Commented:
Balshe,

I was thinking of some sort of event driven solution, but I think I can use what you suggest.

Thanks,

Bill
0
mokuleCommented:
Balshe's solution works only once.
Strange You accept it.
0
wipnavAuthor Commented:
It's the concept of simply checking if the date changed, not the actual implementation, that I accepted as a solution.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.