Open TDateTimePicker with code

I wish to open a TDateTimePicker with code. How may this be accomplished? (The DropDown method does not work for this component, before you try!)
egarsonAsked:
Who is Participating?
 
ronit051397Connect With a Mentor Commented:
procedure TForm1.Button1Click(Sender: TObject);
begin
  DateTimePicker1.Setfocus;
  keybd_event(VK_F4,0,0,0);
  keybd_event(VK_F4,0,KEYEVENTF_KEYUP,0)
end;

0
 
egarsonAuthor Commented:
Well done, Ronit!!

Why don't you comment the code a little so that we may benefit from your considerable wealth of knowledge? The two API calls are quite cryptic without any explanation.

Regards,

Edward
0
 
egarsonAuthor Commented:
Ronit,

I just noticed that the code only works if the picker tpype is set to date; how does one open it if the type is set to Time?
0
 
ronit051397Commented:
When you are focused on any combobox, and you press F4, the combo drops down. This code simulate the keystroke F4:
line 1 - setting the focus
line 2 - simulating F4 key down
line 3 - simulating F4 key up

If you set to Time mode, you cannot open a combo, even by clicking it, cause there is no combobox in time mode, or any other 'dropping' time screen.
0
 
egarsonAuthor Commented:
Yes, I jumped the gun concerning dropping down the dktTime kind for TDateTimePicker....

Regards,

Edward
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.