View Issue Details

IDProjectCategoryView StatusLast Update
0036718LazarusPackagespublic2021-03-15 15:02
ReporterAndrey Zubarev Assigned ToMichl  
PrioritynormalSeverityminorReproducibilityhave not tried
Status assignedResolutionopen 
Product Version2.0.7 (SVN) 
Summary0036718: AnchorDocking: wrong main window size ater layout loading with LCL scaling
DescriptionWrong main window size ater layout loading with LCL scaling. See Steps To Reproduce

This is most likely because in step 4 layout.xml is loaded into the onCreate handler and some scaling parameters have not yet been configured. Reloading at runtime does everything correct. How do I get around this?
Steps To Reproduce1. Open components\anchordocking\minidewithdockpanel example
2. Set Project Options <-> Use LCL scaling (Hi-DPI) to true
3. Run example and save your layout to layout.xml
4. ReRun example and see wrong window size
5. Load layout.xml manually and see correct window size
TagsNo tags attached.
Fixed in Revision
LazTarget-
Widgetset
Attached Files

Relationships

related to 0034841 closedPascal Riekenberg AnchorDocking: Loading layouts does not consider HighDPI scaling 

Activities

Andrey Zubarev

2020-02-20 18:29

reporter   ~0121178

oops. typo, should be:
*This is most likely because in step 4 layout.xml is loaded into the onCreate handler

Juha Manninen

2020-02-21 20:31

developer   ~0121185

Changed "step 3" -> "step 4".

Pascal Riekenberg

2021-03-15 12:00

developer   ~0129685

You are right, layout is loaded before LCL scaling has been done.
Just load the layout in OnShow instead. See attached patch.
minidewithdockpanel.patch (1,384 bytes)   
Index: unit1.lfm
===================================================================
--- unit1.lfm	(revision 64816)
+++ unit1.lfm	(working copy)
@@ -9,6 +9,7 @@
   DesignTimePPI = 113
   Menu = MainMenu1
   OnCreate = FormCreate
+  OnShow = FormShow
   LCLVersion = '1.9.0.0'
   object LeftCoolBar: TCoolBar
     Left = 0
Index: unit1.pas
===================================================================
--- unit1.pas	(revision 64816)
+++ unit1.pas	(working copy)
@@ -50,6 +50,7 @@
     procedure AnchorDockPanel1Create(Sender: TObject);
     procedure FileMenuItemClick(Sender: TObject);
     procedure FormCreate(Sender: TObject);
+    procedure FormShow(Sender: TObject);
     procedure InfoButtonClick(Sender: TObject);
     procedure LoadLayoutMenuItemClick(Sender: TObject);
     procedure LoadLayoutToolButtonClick(Sender: TObject);
@@ -174,8 +175,6 @@
   DockMaster.OnCreateControl:=@DockMasterCreateControl;
   DockMaster.OnShowOptions:=@ShowAnchorDockOptions;
 
-  LoadLayoutToolButtonClick(self);
-
   //SetBounds(100,50,600,80);
   //ViewSrcEditor1ToolButtonClick(Self);
   //ViewMessagesToolButtonClick(Self);
@@ -183,6 +182,11 @@
   //ViewFPDocEditorToolButtonClick(Self);
 end;
 
+procedure TMainIDE.FormShow(Sender: TObject);
+begin
+  LoadLayoutToolButtonClick(self);
+end;
+
 procedure TMainIDE.InfoButtonClick(Sender: TObject);
 var
   aForm: TForm;
minidewithdockpanel.patch (1,384 bytes)   

Andrey Zubarev

2021-03-15 13:11

reporter   ~0129687

Yes, so everything works fine. But is this the right decision?
As far as I understand - OnShow can be called many times during the running of the program. You need to additionally take care that the layout loading is carried out only once

Pascal Riekenberg

2021-03-15 15:01

developer   ~0129689

This was just meant to get this example working. Someone has to take a look why OnCreate event is insufficient for loading layout. I had a similar problem in my project with constructor vs. OnCreate event.

Issue History

Date Modified Username Field Change
2020-02-20 14:12 Andrey Zubarev New Issue
2020-02-20 18:29 Andrey Zubarev Note Added: 0121178
2020-02-21 20:30 Juha Manninen Description Updated View Revisions
2020-02-21 20:30 Juha Manninen LazTarget => -
2020-02-21 20:31 Juha Manninen Note Added: 0121185
2021-03-02 21:22 Michl Relationship added related to 0034841
2021-03-15 12:00 Pascal Riekenberg Note Added: 0129685
2021-03-15 12:00 Pascal Riekenberg File Added: minidewithdockpanel.patch
2021-03-15 13:11 Andrey Zubarev Note Added: 0129687
2021-03-15 15:01 Pascal Riekenberg Note Added: 0129689
2021-03-15 15:01 Pascal Riekenberg Assigned To => Pascal Riekenberg
2021-03-15 15:01 Pascal Riekenberg Status new => assigned
2021-03-15 15:02 Pascal Riekenberg Assigned To Pascal Riekenberg => Michl