View Issue Details

IDProjectCategoryView StatusLast Update
0036493LazarusLCLpublic2020-01-05 13:18
ReporterChris Rorden Assigned To 
Status newResolutionopen 
PlatformMacBook 2012 Retina 13"OSDarwin 
Product Version2.1 (SVN) 
Summary0036493: Form with autosize := true does not consider width of TPageControl TTabSheet
DescriptionThis seems to be a general problem when a Form has AutoSize of true where the labels for the tabbed page control are wider than the window contents. The form is sized for the contents ignoring the requirements of the tabs.
Steps To ReproduceSet a Form to AutoSize = true, add a PageControl, Add several pages and set each tab sheet to have a long name. Run the program.
TagsNo tags attached.
Fixed in Revision
Attached Files


related to 0035858 closedJuha Manninen GTK2: Form AutoSize does not take menu size into account with bsSingle 


Chris Rorden

2019-12-29 13:51

reporter (119,380 bytes)

Chris Rorden

2019-12-29 13:52

reporter   ~0120131

Example project on different widget sets, so seems to be general LCL problem, not specific to one widget set.
gtk2.png (15,897 bytes)   
gtk2.png (15,897 bytes)   
gtk3.png (11,579 bytes)   
gtk3.png (11,579 bytes)   
qt5.png (14,790 bytes)   
qt5.png (14,790 bytes)   
cocoa.png (49,471 bytes)   
cocoa.png (49,471 bytes)   

Dmitry Boyarintsev

2020-01-04 20:29

developer   ~0120223

here's a proposed patch
tabwidth.diff (1,707 bytes)   
Index: lcl/comctrls.pp
--- lcl/comctrls.pp	(revision 62492)
+++ lcl/comctrls.pp	(working copy)
@@ -587,6 +587,9 @@
     procedure DoRemoveDockClient(Client: TControl); override;
     function DoUndockClientMsg(NewTarget, Client: TControl):boolean; override;
     function ChildClassAllowed(ChildClass: TClass): boolean; override;
+    procedure GetPreferredSize(var PreferredWidth, PreferredHeight: integer;
+                               Raw: boolean = false;
+                               WithThemeSpace: boolean = true); override;
     function FindNextPage(CurPage: TTabSheet;
                           GoForward, CheckTabVisible: Boolean): TTabSheet;
Index: lcl/include/
--- lcl/include/	(revision 62492)
+++ lcl/include/	(working copy)
@@ -116,6 +116,23 @@
   if Widgetset.GetLCLCapability(lcAllowChildControlsInNativeControls) = LCL_CAPABILITY_YES then Result := True;
+procedure TPageControl.GetPreferredSize(var PreferredWidth,
+  PreferredHeight: integer; Raw: boolean; WithThemeSpace: boolean);
+  i : integer;
+  r : TRect;
+  inherited GetPreferredSize(PreferredWidth, PreferredHeight, Raw,
+    WithThemeSpace);
+  for i:=0 to PageCount-1 do begin
+    if Pages[i].TabVisible then begin
+      r:=TabRect(i);
+      //PreferredWidth:=Max(Min(Width, r.Right), PreferredWidth);
+      PreferredWidth:=Max(r.Right, PreferredWidth);
+    end;
+  end;
 function TPageControl.FindNextPage(CurPage: TTabSheet; GoForward,
   CheckTabVisible: Boolean): TTabSheet;
tabwidth.diff (1,707 bytes)   

Chris Rorden

2020-01-05 13:18

reporter   ~0120229

Dmitry, thanks for the patch. It improves things on GTK2. However, the preferred size seems to be based on the active page used when the form is first displayed. In my example, set the "ActivePage" of From2/PageControl1 to "TabSheet2" - this is a smaller tab sheet. Now when you run the program the program initially appears with the correct (small) form size, but clicking to the larger "TabSheet1" does not change the form size, so content is not visible.

Issue History

Date Modified Username Field Change
2019-12-29 13:51 Chris Rorden New Issue
2019-12-29 13:51 Chris Rorden File Added:
2019-12-29 13:52 Chris Rorden File Added: gtk2.png
2019-12-29 13:52 Chris Rorden File Added: gtk3.png
2019-12-29 13:52 Chris Rorden File Added: qt5.png
2019-12-29 13:52 Chris Rorden File Added: cocoa.png
2019-12-29 13:52 Chris Rorden Note Added: 0120131
2020-01-01 23:43 Juha Manninen Relationship added related to 0035858
2020-01-04 20:29 Dmitry Boyarintsev File Added: tabwidth.diff
2020-01-04 20:29 Dmitry Boyarintsev Note Added: 0120223
2020-01-05 13:18 Chris Rorden Note Added: 0120229