Issue on TPageControl lazarus / 31-LCL ---------------------------------------------------------------------- tintinux · 2014-03-14 10:13 Hi I have a Form with a TPageControl containing several TabSheets. It was working fine up to 1.0.14, but no more on 1.2 Windows 64 . I have not tried others for now. Both in the EDI (design time) and at run time I see only the first Tab. The property ShowTabs is true. If I set this property to False and then to True, I can see all other Tabs. This works again at design and run time. However at designtime, I must do this every time after I open the form, or else insert the workaround in the Loaded procedure of a subclassed component. Code: [Select]procedure TGPageControl.Loaded; begin   inherited Loaded;   // workaround for a bug in 1.2   ShowTabs:= False ;   ShowTabs:= True ; end;  The strange thing is that I have other very similar forms with a TPageControl and no problem, all tabs are shown as expected, and this is not reproductible on a small example. I guess the property is not always properly initialized or used. I'd like to know if someone has experienced this issue, or already reported the bug. Regards ---------------------------------------------------------------------- Martin_fr · 2014-03-14 10:23 There is a similar (but slightly different) report: http://bugs.freepascal.org/view.php?id=25555 But no one was yet able to reproduce it. 1) Please try the 2 suggestions from http://bugs.freepascal.org/view.php?id=25555#c73094 2) Report as new bug, AND provide an example to reproduce the issue. ---------------------------------------------------------------------- tintinux · 2014-03-18 09:33 Hi I have tried to isolate the bug and found it was due to the sequence below, that I have written in a subcomponent, inheriting from TEdit. This component was on the first TabSheet of the TPageControl, and called this procedure during its OnCreate : Code: [Select]procedure SetFEditSize ; var   W : integer;   c: TControlCanvas; begin     c:=TControlCanvas.Create;     try       c.control:=Fedit;       W := C.TextWidth(StringOfChar('W', FEdit.MaxLength ) );       [.....] end ; Removing the line W := C.TextWidth does suppress the non painting of the second TabSheet !!!! A fix, which works fine on my sample (but must be tested in more situations) is to avoid calling this procedure before the component was loaded. Code: [Select]  if not (csLoading in ComponentState) then     SetFEditSize ; I agree that it was stupid  to query the textwidth before loading, BUT it is really weird  that this can alter the display of tabsheets, and this only in 1.2 not in 1.0.14. Ok, this is not a bug in Lazarus, but isn't it possible to make a more robust code to avoid this bad side effect  when calling TextWidth in a wrong place ? Maybe other reported bugs could have similar causes and effects. This is too complex for my knowledge, but maybe one of the gurus could have a look... Thanks ---------------------------------------------------------------------- Martin_fr · 2014-03-18 11:01 is that a try...except or try...finally? Because if FEdit is not initialized yet, then " FEdit.MaxLength" may crash. The problem is that the exception may be caught some place else, and you may not get to see it. But it an exception during loading can abort the loading. ---------------------------------------------------------------------- tintinux · 2014-03-18 13:15 It is a try finally and I'm sure that FEdit is initialized. In an earlier version, there was no try and the TControlCanvas was not freed (bad, I agree) and it was the same issue. Regards ---------------------------------------------------------------------- Martin_fr · 2014-03-18 13:19 If you run it in the debugger, are there any exceptions shown? ---------------------------------------------------------------------- tintinux · 2014-03-18 13:58 No exception are raised. ---------------------------------------------------------------------- Martin_fr · 2014-03-18 14:11 Interesting. Do you have a small example, self contained, that will reproduce this? ---------------------------------------------------------------------- Martin_fr · 2014-03-18 21:48 There was an issue, indeed where creating a handle while loading caused a tab sheet to be kept hidden. Fixed in SVN, and flagged for merging to 1.2.2 ---------------------------------------------------------------------- tintinux · 2014-03-19 09:17 Good news ! In case you still want the example I have made, before reading your last post, it is attached. See the readme.txt. Regards