[Solved] Need to call paint manually for TDateTimePicker lazarus / 31-LCL ---------------------------------------------------------------------- Murray_B · 2017-06-15 11:41 Hi! I am building a calendar/organizer with lazarus and have a form to enter or edit a calendar entry. There are TDateTimePickers for start and end of the event. I start the app, look at the first entry and everything is fine. I close the form and try to view the next calender entry and it has the same values for start and end as the first one. If you try to edit the field you find out that the right value is stored but not shown. So I tried a startdate.paint after I filled the TDateTimePicker with values and it shows the right date. But also all the other TDateTimePickers were correct after I did "paint" on ONE of them! This problem only occurs on the TDateTimePicker not on normal edit fields or others. Somethings is wrong there, but I don't know what. I also tried to show the form and fill it later, that doesn't work better. Any ideas? Thanks in advance! I am using lazarus-gtk on linux 64 bit. ---------------------------------------------------------------------- zeljko · 2017-06-15 12:12 How can anyone help you without any code or example project ? Also what version of lazarus do you use ? ---------------------------------------------------------------------- Murray_B · 2017-06-15 13:19 Okay, sorry, I am new to this forum, I never thought anybody would like to read my whole project. You can download the source at http://www.thschuetz.de/temp/LOrga- Source.zip I reset the TDateTimePicker in ucaldata.pas in line line 668-675 with default values and write the values from the calendar file into it at line 721-724, in line 744 I call ShowModal and in 745 I do a repaint. Some short code: EditStartDate.Date:=Date();  //reset EditStartDate.DateTime:=int(Tcalevent(eventlist[currentevent]).start); //fill with stored data self.Showmodal();  // show form EditStartDate.Paint; // make form show the start date I think the code is quite boring, but the last line shouldn't be needed, should it? I am using lazarus current, 1.6.4. My application is in german, so some hints to produce the error: - start it - press "Termin anzeigen" to show the first entry and look at "Beginn" and "Ende" for the start and the end of the entry. - press "Abbrechen" (abort) - increment the number to 1, 2, 3 etc. to show another entry and press "Termin anzeigen" - the dates at "Beginn" and "Ende" do not change without the EditStartDate.Paint Okay, I try to serve better informations in future. ---------------------------------------------------------------------- Handoko · 2017-06-15 14:27 I tested your code. I can confirm what @Murray_B said is also happened on my Ubuntu 16.10 Lazarus 1.6.4 64-bit Gtk2: - without EditStartDate.Paint, it showed the previous calender (but the stored value is different) - with EditStartDate.Paint, the calender showed correctly I am going to do more tests and will be back. ---------------------------------------------------------------------- zeljko · 2017-06-15 14:32 I don't see any problem with your project here. Using Lazarus 1.9 trunk r55021. Tested gtk2 and qt and both works fine. Fedora 24 64bit, fpc-3.0.2. So, that means that something is fixed in between, but don't know exactly what. Never call EditStartDate.Paint, but EditStartDate.Repaint if you need it at all because Self.ShowModal blocks until finished and calling paint after that means exactly nothing since after showmodal form is at least invisible. Try to call repaint or update of control inside OnFormShow() event and see if that helps. ---------------------------------------------------------------------- Handoko · 2017-06-15 16:22 I wrote and tested a simple test, and yes TDateTimePicker has problem on my Linux64 and Win32 (Wine on Ubuntu). On the Bugtracker, the problem has been reported since March 2017 and it marked as resolved in revision 54495: https://bugs.freepascal.org/view.php?id=31571 This is my test code: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; {$mode objfpc}{$H+} interface uses  SysUtils, DateTimePicker, Forms, StdCtrls; type   { TForm1 }   TForm1 = class(TForm)    Button1: TButton;    Edit1: TEdit;    procedure Button1Click(Sender: TObject);  end; var  Form1: TForm1; const  Newform: TForm = nil;  DatePicker: TDateTimePicker = nil; implementation {$R *.lfm} { TForm1 } procedure TForm1.Button1Click(Sender: TObject);var  NewDate: TDateTime;begin  if (Newform = nil) then  begin    Newform := TForm.Create(Self);    Newform.Position := poDesktopCenter;    DatePicker := TDateTimePicker.Create(Newform);    with DatePicker do    begin      Parent := Newform;      Left := 40;      Top := 10;    end;  end;  if TryStrToDate(Edit1.Text, NewDate) then  begin    DatePicker.Date := NewDate;    Newform.ShowModal;  end;end; end. ---------------------------------------------------------------------- Zoran · 2017-06-15 18:39 Handoko, with which Lazarus version did you test? With your code I cannot reproduce with Lazarus 1.8 fixes branch or with Lazarus trunk. I don't have 1.6 any more. ---------------------------------------------------------------------- Handoko · 2017-06-15 18:49 Lazarus 1.6.4 64-bit Gtk2. ---------------------------------------------------------------------- Zoran · 2017-06-15 18:56 Quote from: Handoko on June 15, 2017, 08:49:30 pmLazarus 1.6.4 64-bit Gtk2. I compiled Lazarus 1.6-fixes on Windows and still cannot reproduce... Handoko, could you please test with 1.8? If the bug is still there, I am very interested in fixing it before 1.8 gets finally released. ---------------------------------------------------------------------- Handoko · 2017-06-16 08:50 The problem have fixed. I tested on Lazarus 1.8.0RC2 x86_64-linux-gtk2 both Linux64 and Win32 (Wine on Ubuntu), the issue cannot be reproduced. ---------------------------------------------------------------------- Zoran · 2017-06-16 10:04 Quote from: Handoko on June 16, 2017, 10:50:21 amThe problem have fixed. I tested on Lazarus 1.8.0RC2 x86_64-linux-gtk2 both Linux64 and Win32 (Wine on Ubuntu), the issue cannot be reproduced. Thank you very much, Handoko. @Murray_B: Please install 1.8. It is currently in release process -- you can download RC2 or, even better, use subversion with 1.8 fixes branch -- see: http://wiki.freepascal.org/Getting_Lazarus#Getting_SVN_client, to get 1.8 fixes use command Code: [Select]svn co http://svn.freepascal.org/svn/lazarus/branches/fixes_1_8 and build it with "make clean bigide". ---------------------------------------------------------------------- Murray_B · 2017-06-17 20:08 Okay, I did what you told me and the error is gone, thank you! btw, I am using the IDE with the docking extension, that is easier with your own build of lazarus from svn than installing a package and recompiling with linux. So I learned another great thing with that error. Another "btw": I tested Lazarus years ago and thought that there is VERY much to do, but today it is really a great IDE, I can't understand why most people are irritaded if you tell him about coding with pascal/lazarus. Great tool, go on with it!