Solved

TDateTimePicker??!!

Posted on 2001-07-18
6
172 Views
Last Modified: 2010-04-06
Imagine there is a TDateTimePicker on the form which displayed my birth date which is 11/12/1978.  When I have the DateTimePicker dropped down, and I will see a calendar.  I don't click on any of the date and then I click anywhere outside the calendar and the datetimepicker. And it results in the calendar being closed up.  At the same time,  the date is changed to current date.  What can I do to prevent the change of my birth date to current date?
0
Comment
Question by:ivylnm
6 Comments
 
LVL 3

Expert Comment

by:Stefaan
ID: 6297039
Hi,

Are you sure about this ? I created a new application and dropped a TDateTimePicker on the form, set the date to 11/12/78, made the date time picker open up, clicked somewhere else on the form, and didn't have it.

By the way, do you have RxLib components installed on your PC ? They contain much better date pickers than the original Delphi one.

Best regards,


Stefaan
0
 
LVL 5

Accepted Solution

by:
Draak earned 50 total points
ID: 6297053
Are you sure this happens? I cannot reproduce this behaviour with Delphi 5. The date does not change when i click outside the DateTimePicker.

Anyhow, you can prevent it by setting the birthdate in the OnCloseUp event of the DateTimePicker.

Okay i found out what to do:

1. declare global variable datechanged of boolean
2. in the DateTimePickerChange event set datechanged to true
3. in the datetimepickerCloseUp event check if datechanged = true. If not, set the datetimepicker back to your birthdate.

see the code I created to do this.

best regards

draak

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ComCtrls;

type
  TForm1 = class(TForm)
    DateTimePicker1: TDateTimePicker;
    procedure DateTimePicker1CloseUp(Sender: TObject);
    procedure DateTimePicker1Change(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  datechanged: boolean;

implementation

{$R *.DFM}

procedure TForm1.DateTimePicker1CloseUp(Sender: TObject);
var mydate:tdatetime;
begin
 if datechanged = false then
 begin
   mydate:= encodedate(1978,12,11);
   DateTimePicker1.date := mydate;
 end;
 datechanged := false;
end;

procedure TForm1.DateTimePicker1Change(Sender: TObject);
begin
 datechanged := true;
end;

end.


0
 
LVL 2

Expert Comment

by:Felixin
ID: 6298170
Which version of Internet Explorer do you have?

Stupid question?. TDateTimePicker is a wrap-up of an ActiveX component that only works form IE 4.01 (if I remember well).
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 21

Expert Comment

by:gemarti
ID: 6300332
Here's a thought:

If you click on the form and the date changes you could be triggering a command like:

  DateTimePicker1.Date := DateTimePicker1.DesignInfo;

or

    DateTimePicker1.Date := Date;


Why don't you post the unit information.

0
 

Author Comment

by:ivylnm
ID: 6300806
It really happens in my program.  After I key in my name 'IVY' , my birthdate is retrieved from database eg. 11/12/1978.  Then I click on the button on the TDateTimePicker, and it has a calendar dropped down.   I click elsewhere from the calendar and the TDateTimePicker.  It appears to change my birthdate 11/12/1978 to current date time.  I am using Delphi 4.  
0
 
LVL 5

Expert Comment

by:Draak
ID: 6301007
then use my solution. That should solve the program. Also consider upgrading to Delphi 5. Maybe the phenomenon you are experiencing is a bug in Delphi 4

best regards

draak
0

Featured Post

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.

Question has a verified solution.

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

Suggested Solutions

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
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…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

733 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