Solved

TDateTimePicker Delphi 7 - BUG using XPManifest

Posted on 2004-08-13
5
1,355 Views
Last Modified: 2007-12-19
Hi Chaps,

I've found a very bad problem with the TDateTimePicker that I think borland should know about (don't know how to report it).

(Using Delphi 7 and Windows XP)

Try the following.

- Create a new application.
- On the form place the following...
- 1 dateTimePicker
- 2 Buttons
- 1 Edit Box
- 1 XP Manifect Component

Now create the following events.

- OnFormCreate
- Button1Click
- Button2Click
- DateTimePicker1Exit

Place in the following code...

procedure TForm1.DateTimePicker1Exit(Sender: TObject);
begin
      Edit1.Text := DateToStr(DateTimePicker1.DateTime);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
   DateTimePicker1.DateTime := StrToDate('02/01/2004');
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
      DateTimePicker1.DateTime := StrToDate('02/01/2004');
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
      //
end;


Ok, here is the problem.  The DateTimePicker does not seem to fire it's internal change event sometimes when using the XP skin.

Example 1.

- Run the application
- Click Button 1
- (Edit1's text will say '02/01/2004') ......{or whatever regional format you have set up}
- Click in the datetimepicker on the first digit and press the down arrow key to change it to '01/01/2004'
- Click Button 1
- (Edit1's text will say '01/01/2004')
- Click in the datetimepicker on the first digit and press the down arrow key to change it to '01/01/2004' (again)
- Click Button 2 this time (button 2 has no code and it's only used to demonstrate loosing focus from the datetimepicker)

- Edit 1's text will now say 02/01/2004 when the date is actually saying 01/01/2004, which is obvisouly very wrong.

Example 2.

- Run the application
- Click the down arrown on the DTPicker.
- Click the red today box
- (DTPicker changes to show todays date)
- Click button 1
- (DTPicker changes to show '02/01/2004')
- Click the down arrown on the DTPicker.
- Click the red today box

- DTPicker STILL says 02/01/2004

Again this is obvisouly wrong.

If you take off the XPManifest control and remove XPMan from the uses at the top of the unit the control works fine!!

The question :

Does anyone have any code that fixes these bugs and does borland know about them?

-

In ComCtrls we found that changing the top part of the CNNotify of the DTPicker control to the following fixes my 'Example 2' bug but we don't have a fix for 'Example 1' yet.

- code fix for example 2.

procedure TDateTimePicker.CNNotify(var Message: TWMNotify);
var
  DT: TDateTime;
  AllowChange: Boolean;
  ST: TSystemTime;
begin
  with Message, NMHdr^ do
  begin
    Result := 0;
    case code of
      DTN_CLOSEUP:
        begin
          FDroppedDown := False;
          //SetDate(SystemTimeToDateTime(FLastChange));

          //**
          DateTime_GetSystemTime(Handle, ST);
          DT := SystemTimeToDateTime(st);
          if Kind = dtkDate then
            SetDate(DT)
          else
            SetTime(DT);
          if FShowCheckbox then FChecked := True;
          Change;
          //**

          if Assigned(FOnCloseUp) then FOnCloseUp(Self);
        end;
      DTN_DATETIMECHANGE:
        begin

etc...


Many Thanks
Woody
0
Comment
Question by:WoodyJ007
5 Comments
 
LVL 12

Expert Comment

by:esoftbg
ID: 11797803
Can be downloaded this TXPManifest for free ?
0
 

Author Comment

by:WoodyJ007
ID: 11807515
XPManifest is a standard borland component in Delphi 7.  It's under the Win32 tab.
0
 

Accepted Solution

by:
modulo earned 0 total points
ID: 13404432
PAQed with points refunded (500)

modulo
Community Support Moderator
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone 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

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…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

828 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