Solved

TDateTimePicker Delphi 7 - BUG using XPManifest

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

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

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…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

747 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

15 Experts available now in Live!

Get 1:1 Help Now