Solved

TDateTimePicker??!!

Posted on 2001-07-18
6
170 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

813 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

8 Experts available now in Live!

Get 1:1 Help Now