Solved

TDateTimePicker??!!

Posted on 2001-07-18
6
167 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 21

Expert Comment

by:gemarti
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

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…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

771 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

11 Experts available now in Live!

Get 1:1 Help Now