Can you test this with TDatetimePicker on something else than Windows 7 ?
Can you test this with TDatetimePicker on something else than Windows 7 ?
Put a DTP and a Memo on a form
set the DTP OnChange event to log its date in the memo
procedure TForm1.DateTimePicker1Change(Sender: TObject);
begin
Memo1.Lines.Add(DateToSTr(DateTimePicker1.Date));
end;
when I select a date, the OnChange event is fired twice.
Worst, if you set Min/MaxDate properties and you click on the dropdown calendar, the OnChange event is fired twice and, the first time, the Date value is the MaxDate !
I've found a workaround, can you test it also ?
type
TDateTimePicker = class(Vcl.ComCtrls.TDateTimePicker)
private
FIgnoreChange: Boolean;
public
procedure WMNotify(var Msg: TWMNotifyDT); message WM_NOTIFY;
procedure Change; override;
end;
procedure TDateTimePicker.WMNotify(var Msg: TWMNotifyDT);
begin
if Msg.NMHdr.code = MCN_SELCHANGE then
FIgnoreChange := True;
inherited;
end;
procedure TDateTimePicker.Change;
begin
if FIgnoreChange then
FIgnoreChange := False;
else
inherited;
end;
Put a DTP and a Memo on a form
set the DTP OnChange event to log its date in the memo
procedure TForm1.DateTimePicker1Change(Sender: TObject);
begin
Memo1.Lines.Add(DateToSTr(DateTimePicker1.Date));
end;
when I select a date, the OnChange event is fired twice.
Worst, if you set Min/MaxDate properties and you click on the dropdown calendar, the OnChange event is fired twice and, the first time, the Date value is the MaxDate !
I've found a workaround, can you test it also ?
type
TDateTimePicker = class(Vcl.ComCtrls.TDateTimePicker)
private
FIgnoreChange: Boolean;
public
procedure WMNotify(var Msg: TWMNotifyDT); message WM_NOTIFY;
procedure Change; override;
end;
procedure TDateTimePicker.WMNotify(var Msg: TWMNotifyDT);
begin
if Msg.NMHdr.code = MCN_SELCHANGE then
FIgnoreChange := True;
inherited;
end;
procedure TDateTimePicker.Change;
begin
if FIgnoreChange then
FIgnoreChange := False;
else
inherited;
end;
this is under Windows 8.1
ReplyDeletehttps://plus.google.com/photos/...
strange I have the same bug with W10/Tokyo
ReplyDeletebut they are several bugs in TDateTimePicker anyway
quality.embarcadero.com - Log in - Embarcadero Technologies
https://quality.embarcadero.com/browse/RSP-21555
Paul TOTH window 10 your fix works
ReplyDeletehttps://quality.embarcadero.com/browse/RSP-21606
ReplyDelete