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
Solved

Handling TDateTimePicker events

Posted on 2007-03-17
8
293 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
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

809 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