View Issue Details

IDProjectCategoryView StatusLast Update
0032379LazarusLCLpublic2017-09-09 15:41
ReporterSonerAssigned Towp 
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Platformi386OSWindowsOS Versionxp,7,10
Product Version1.8RC4Product Buildsvn-rev. 55760 
Target Version1.8Fixed in Version1.8 
Summary0032379: TCalenderDialog doesn't show initial date.
DescriptionTCalenderDialog doesn't show initial date. It shows current date.
Steps To Reproduce1. Put on a form TCalendarDialog
2. Change CalendarDialog1.Date in object inspector
3. Right click on form designer to CalendarDialog1 and select [test dialog..]

or
1. Create project and put on a form TCalendarDialog and a Button
2. double click on button
3. write on Button1Click:
procedure TForm1.Button1Click(Sender: TObject);
begin
  CalendarDialog1.Date:=EncodeDate(2016,1,10);
  if CalendarDialog1.Execute then
    ShowMessage('You select '+DateToStr(CalendarDialog1.Date));
end;

4. build and execute the app
Additional Informationsame result with lazarus 1.6.4
TagsNo tags attached.
Fixed in Revisionr55820
LazTarget1.8
WidgetsetWin32/Win64
Attached Files
  • extdlgs.pas.patch (546 bytes)
    Index: lcl/extdlgs.pas
    ===================================================================
    --- lcl/extdlgs.pas	(revision 55791)
    +++ lcl/extdlgs.pas	(working copy)
    @@ -732,6 +732,7 @@
     
     procedure TCalendarDialog.OnDialogShow(Sender: TObject);
     begin
    +  FCalendar.DateTime := FDate;
       DoShow;
     end;
     
    @@ -801,7 +802,6 @@
         with FCalendar do begin
           Parent:=DlgForm;
           Align:=alTop;
    -      DateTime:=Self.Date;
           TabStop:=True;
           DisplaySettings:=Self.DisplaySettings;
           OnDayChanged:=@Self.OnCalendarDayChanged;
    
    extdlgs.pas.patch (546 bytes)

Activities

wp

2017-09-06 22:58

developer  

extdlgs.pas.patch (546 bytes)
Index: lcl/extdlgs.pas
===================================================================
--- lcl/extdlgs.pas	(revision 55791)
+++ lcl/extdlgs.pas	(working copy)
@@ -732,6 +732,7 @@
 
 procedure TCalendarDialog.OnDialogShow(Sender: TObject);
 begin
+  FCalendar.DateTime := FDate;
   DoShow;
 end;
 
@@ -801,7 +802,6 @@
     with FCalendar do begin
       Parent:=DlgForm;
       Align:=alTop;
-      DateTime:=Self.Date;
       TabStop:=True;
       DisplaySettings:=Self.DisplaySettings;
       OnDayChanged:=@Self.OnCalendarDayChanged;
extdlgs.pas.patch (546 bytes)

wp

2017-09-06 23:07

developer   ~0102677

Last edited: 2017-09-06 23:09

View 2 revisions

I can confirm that the issue occurs on Windows and Linux (gtk2 and qt). Yes, it does happen with Laz versions back to 1.6.4, but not with 1.6.2 and earlier.

It looks to me that setting the date in the construction phase of TCalendarDialog.Execute is too early. Delaying it until the dialog is shown (TCalendarDialog.OnDialogShow) makes the requested date appear (see extdlgs.pas.patch). This works for Windows and Linux.

Not sure, however, if this only cures the sympton but leaves the real problem untouched...

Soner

2017-09-08 20:33

reporter   ~0102724

I located the problem.
TCustomCalendar.InitializeWnd called twice. At first call SetProps; is called. And SetProps sets date and FPropsChanged to false.
Maybe second call is the right call to set date, but the SetProps is no more called because Fpropschanged is false.
Here is the function from calendar.pp:

procedure TCustomCalendar.InitializeWnd;
begin
  inherited InitializeWnd;
  if FPropsChanged then SetProps;
end;

-----
When you change:
if FPropsChanged then SetProps;
to
SetProps;
then the problem is "solved".

wp

2017-09-08 23:58

developer   ~0102728

Last edited: 2017-09-09 00:03

View 2 revisions

Yes. Applied in r55820. Thanks. Please test, and close if ok.

Issue History

Date Modified Username Field Change
2017-09-06 17:34 Soner New Issue
2017-09-06 22:58 wp File Added: extdlgs.pas.patch
2017-09-06 23:07 wp Note Added: 0102677
2017-09-06 23:09 wp Note Edited: 0102677 View Revisions
2017-09-08 20:33 Soner Note Added: 0102724
2017-09-08 23:58 wp Fixed in Revision => r55820
2017-09-08 23:58 wp LazTarget => 1.8
2017-09-08 23:58 wp Note Added: 0102728
2017-09-08 23:58 wp Status new => resolved
2017-09-08 23:58 wp Fixed in Version => 1.8
2017-09-08 23:58 wp Resolution open => fixed
2017-09-08 23:58 wp Assigned To => wp
2017-09-08 23:58 wp Target Version => 1.8
2017-09-09 00:03 wp Note Edited: 0102728 View Revisions
2017-09-09 15:41 Soner Status resolved => closed