Solved

Handling TDateTimePicker events

Posted on 2007-03-17
8
296 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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
 
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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
how to center only a line in richedit? 4 78
Multiple image collision 13 108
CheckListBox usage 3 97
firemonkey keyboard covers the controls 1 83
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

734 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