?
Solved

TDateTimePicker??!!

Posted on 2001-07-18
6
Medium Priority
?
176 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
[X]
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
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 150 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month13 days, 19 hours left to enroll

801 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