Solved

Handling TDateTimePicker events

Posted on 2007-03-17
8
291 Views
Last Modified: 2013-11-23
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
0
Comment
Question by:wipnav
  • 3
  • 3
  • 2
8 Comments
 
LVL 17

Expert Comment

by:mokule
ID: 18743057
try to use OnCloseUp event

procedure TForm1.DateTimePicker1CloseUp(Sender: TObject);
begin
  // do whatever
end;
0
 
LVL 1

Expert Comment

by:Balshe
ID: 18743798
do you want to know if he picked the date? or just if the user has canceled?
0
 
LVL 1

Author Comment

by:wipnav
ID: 18744938
I need to know if the user cancelled, either because he pressed escape or clicked somewhere else.
0
 
LVL 1

Accepted Solution

by:
Balshe earned 500 total points
ID: 18745034
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 17

Expert Comment

by:mokule
ID: 18745075
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
 
LVL 1

Author Comment

by:wipnav
ID: 18745661
Balshe,

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

Thanks,

Bill
0
 
LVL 17

Expert Comment

by:mokule
ID: 18745721
Balshe's solution works only once.
Strange You accept it.
0
 
LVL 1

Author Comment

by:wipnav
ID: 18745777
It's the concept of simply checking if the date changed, not the actual implementation, that I accepted as a solution.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

895 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now