[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

TDateTimePicker??!!

Posted on 2001-07-18
6
Medium Priority
?
179 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
Industry Leaders: 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

Technology Partners: 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!

Question has a verified solution.

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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

656 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