Solved

TDateTimePicker Delphi 7 - BUG using XPManifest

Posted on 2004-08-13
5
1,345 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
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 …
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…

777 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