Sign in Join
Wiki copytemporary

Anchor Docking: what changed

Revision 1 to 2. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11About docking in general see [[Docking]].
22
33## Overview
44
55Docking allows you to combine forms, or to treat controls as forms. You use the mouse to drag and dock forms together or undock (split) them. The basic dragging, docking and undocking functionality is provided by the LCL. But you need a docking manager to add splitters and grab zones, and to save and restore layouts.
66
77Anchor docking has been implemented since version 0.9.29 in the package *anchordocking.lpk* for use in your own Lazarus applications, and *AnchorDockingDsgn.lpk* if you wish to make the Lazarus IDE windows dockable. It is easy to use, and provides many features and options not available in earlier docking packages.
88
99You will find a code example at: components/anchordocking/miniide/miniide1.lpi
1010
1111This means that the earlier TLazDockingManager and unit LDockCtrl are obsolete and now deprecated.
1212
1313### Features
1414
1515- **Drag and dock**: Headers are added that can be dragged to dock controls with the mouse. Preview rectangles will show where and how a control is docked.
1616- **Any layout**: By using the LCL's anchors almost any layout is possible. You can dock to left, right, top, bottom, inside or outside or as page like in a TPageControl. You can enlarge docked controls via the popup menu. No need to undock your whole layout.
1717- **What you see is how it is structured**: There are no hidden panels to align controls in rows and columns. Anchor docking makes sure forms do not overlap.
1818- **Splitters** are automatically inserted between docked forms to allow resizing.
1919- **Page docking**. Forms can be docked not only left/right/above/below, but in pages too. A TPageControl is automatically created for native look and feel. A page can contain arbitrary docked forms too, including paged docked forms, allowing nested pages and layouts. When a page is undocked the pagecontrol is automatically removed. You can drag and drop the tabs or use the popup menu to move pages.
2020- **Easy use**: With one line of code you can make a form or control dockable. Just give them unique names.
2121- Not only forms, but any **TWinControl** can be made dockable.
2222- Can **save/load layouts**. The layout information is stored for each dockable control and old layout files will still work even when the application gets more dockable controls or some are removed. The information is stored in the abstract class LCL TConfigStorage. So you can use for example TXMLConfigStorage to store layouts in xml files or you can write your own storage to store it wherever you want.
2323- Each docked form is put into a docksite providing an optional **header**. The header shows the caption of the docked form and contains a close button. You can *drag the header* to drag the form and undock it or to dock it at another position. The header can be at any of the four sides and moves by default automatically to the smaller side to save space. You can customize this. The header shows a customizable hint allowing to read long captions.
2424- When a docksite is resized the *child sites are automatically scaled*. You can turn this off.
2525- **Preserve size of forms**. For instance when docking a form to a left side of a site the width of the docked form is kept. The same for the other sides and the same for undocking.
2626- **Flickerless**: The restore tries to reuse existing sites and splitters to reduce creation and flickering of forms and to preserve the Z order of forms. This allows to quickly switch between layouts.
2727- **Header popup menu**:
2828 - lock/unlock (disable dragging)
2929 - header position (auto, left, top, right, bottom), this is saved/restored with the layout
3030 - merge (for example after moving a dock page into a layout)
3131 - undock (needed if no place to undock on screen)
3232 - enlarge side to left, top, right, bottom
3333 - close
3434 - options
3535- **Page popup menu**:
3636 - lock/unlock (disable dragging)
3737 - undock (needed if no place to undock on screen)
3838 - tab position for pagecontrol (top,bottom, left, right), this is saved/restored with the layout
3939 - move page to the left, right, leftmost, rightmost
4040 - close
4141 - options
4242- Forms can be made dock sites. Then they can dock at one side. But they can not be docked itself.
4343- close button automatically saves a layout
4444- Powerful functions to alter the layout. You can use D&D to move a form and you can undock and dock in one move. There are functions to enlarge forms and shrinking others. These functions are available via the header popup menu as well. See below.
4545- There is an IDE package which makes the Lazarus IDE dockable. It is called anchordockingdsgn.lpk. Make sure you only install one docking package. Do not install the easydockmgr at the same time!
4646
4747### ToDos
4848
4949- Design time package: Add all layout files to menu
5050- simple way to make forms dockable at designtime (that means without writing any code)
5151- minimize button and Hide
5252- on show again: restore a default layout
5353- close button for pages
5454- Implement automatic menu merging in the LCL (when two forms with main menus are docked).
5555
5656## Usage I. (Add docking support to the Lazarus IDE)
5757
5858If you don't like the default "separate windows" look of the Lazarus IDE and prefer a single window (e.g., like RAD Studio™), you can install a package called **[[AnchorDockingDsgn]]** (lazarus/components/anchordocking/design/anchordockingdsgn.lpk). This package makes the IDE windows dockable.
5959
6060### Important to macOS users
6161
6262Before Lazarus 3.0, there are many bugs related to docking.
6363
6464If "anchordockingdsgn" has been installed before Lazarus 3.0, the wrong configuration may be saved and needs to be reset first.
6565
6666The configuration is saved in environmentoptions.xml, which usually located in ~/.lazarus
6767
6868Close the IDE, locate environmentoptions.xml, delete the content between \<AnchorDocking\> and \</AnchorDocking\>, and the initial setting of anchordockingdsgn will be automatically set when the IDE is started again.
6969
7070### Installation
7171
7272Uninstall any other docking managers (e.g., easydockmgrdsgn). From the Lazarus menu bar pick "Package" - "Install/Uninstall Packages" and install the "anchordockingdsgn" package.
7373
7474After you have successfully installed the package and restarted the IDE, the IDE starts with a default docked layout like shown below. Note that AnchorDocking headers and splitters have been added to all dockable windows of the IDE. In case the headers don't get visible, see the section "Options" below on how to enable/disable them.
7575
76-<figure>
7776<img src="2021-12-02_10_21_07-Debian_10.8_Buster_-_VMware_Workstation.png" title="2021-12-02_10_21_07-Debian_10.8_Buster_-_VMware_Workstation.png" width="1333" />
78-<figcaption>2021-12-02_10_21_07-Debian_10.8_Buster_-_VMware_Workstation.png</figcaption>
79-</figure>
8077
8178You can change the layout by grabbing a dockable window by the Anchordocking header and drag and dock it anywhere else, or resize docked windows via splitters added to the window borders. You can right-click on the headers too for other options, for example, to change the look of the headers, as shown farther down below.
8279
8380You can save the layout via the menu item **Tools / Save window layout as default**. This saves to ~/.lazarus/anchordocklayout.xml and restores it when the IDE starts up.
8481
8582You can also save the layout to a file and load them later.
8683
8784Since Lazarus 1.1 you can pass a command line parameter
8885
8986`./lazarus --anchordocklayout=<filename>`
9087
9188The look (like the headers) can be further tweaked by right-clicking on them.
9289
93-<figure>
94-<img src="docking_headers.gif" title="docking_headers.gif" />
95-<figcaption>docking_headers.gif</figcaption>
96-</figure>
90+![](/wiki-images/8/8a/Docking_headers.gif)
9791
9892### Options
9993
10094After the successful installation of the AnchorDockingDsgn package, an additional configuration menu is added to the Lazarus options dialog ("Tools" - "Options" - "Environment")
10195
102-<figure>
103-<img src="anchordocking_options.png" title="anchordocking_options.png" />
104-<figcaption>anchordocking_options.png</figcaption>
105-</figure>
96+![](/wiki-images/3/3a/Anchordocking_options.png)
10697
10798#### Scale on resize
10899
109100When resizing a window, all docked forms inside are scaled by the same percentage.
110101
111102#### Show headers
112103
113104To dock/undock a window, you need to enable this option.
114105
115106#### Flatten headers
116107
117108No 3d frame in headers.
118109
119110#### Header align top/left
120111
121112Headers are automatically put at top or left depending on these two values:
122113
123114- Move header to top, when (width/height)*100\<=HeaderAlignTop, default 80
124115- Move header to left, when (width/height)*100\>=HeaderAlignLeft, default 120
125116- Otherwise keep the header at the current position.
126117
127118Which means the header is by default put at the smaller side of a docked control. When the control is resized, the header switches to the smaller side.
128119
129120#### Allow dock sites to be minimized
130121
131122A extra minimize button is added, so a site can be minimized. Then sites next to it get more space. If needed, the minimized site then can easy be opened.
132123
133124#### Multine Tabs
134125
135126Feature added in Lazarus 2.2. If a OS support multiline tabs (like Windows), if there are no many tabs, they are shown in multiple lines.
136127
137128#### Floating windows on top
138129
139130Feature added in Lazarus 2.2. If there are undocked windows shown, show these on top of main window. In a own application, there can be set DockMaster.MainDockForm, then all floating windows are shown on top of it. If MainDockForm is not set, Application.MainForm is used.
140131
141132## Usage II. (Add docking support to your own applications)
142133
143134### Quick start
144135
145136Add the package **AnchorDocking** to the required packages in the project inspector.
146137
147138Then add the unit **AnchorDocking** to the uses section of your main unit (the unit with your main form).
148139
149140Add to the FormCreate of your main form:
150141
151142``` pascal
152143 DockMaster.MakeDockSite(Self,[akBottom],admrpChild);
153144```
154145
155146For the other dockable forms replace all calls of *Show* and *ShowOnTop* with
156147
157148``` pascal
158149 DockMaster.MakeDockable(Form1,true,true);
159150```
160151
161152For the other dockable forms replace all calls of *Visible:=true* with
162153
163154``` pascal
164155 DockMaster.MakeDockable(Form1,true);
165156```
166157
167158Remove or comment all *Hide*, *Visible:=false*, *WindowState:=* calls.
168159
169160### Prerequisites
170161
171162- Your project must use the package *AnchorDocking*.
172163- All dockable forms must be shown with MakeDockable or MakeDockSite. Do not use *Show*, *BringToFront*, *ShowOnTop*, *Visible:=true*. Of course you can have some non dockable forms, like hints or splashscreens.
173164- All dockable forms must be free resizable, that means no constraints, no BorderStyle bsDialog.
174165- No other docking system. AnchorDocking is incompatible with EasyDockMgr.
175166
176167### Making forms dockable
177168
178169There are two ways to make a form dockable. You can use **DockMaster.MakeDockable** to wrap a form into a dock site. Then your form can dock and be docked completely free. You will use that for the biggest part of your forms, except for the MainForm, because this is only supported for the MainForm on gtk2 and qt. The second way is to use **DockMaster.MakeDockSite**. The form can dock other sites, but can not be docked itself. You might want to use *MakeDockSite* for the *MainForm*. For most other forms you probably want to use this:
179170
180171``` pascal
181172// shows YourForm
182173// if not already done, wrap the form into a dock site
183174DockMaster.MakeDockable(YourForm);
184175```
185176
186177Here are some examples how a form looks like that was made dockable with **DockMaster.MakeDockable**:
187178
188179![](/wiki-images/b/bc/Docksite1.png) ![](/wiki-images/c/c6/Docksite2.png)
189180
190181The header position is normally done automatically and the user can with a right click put it to any of the four sides.
191182
192183### Example: miniide1
193184
194185The example can be found in *lazarus/components/anchordocking/miniide/miniide1.lpi*. It has a *mainform* in unit *unit1.pas* with a main menu which works as a docksite and several forms that are dockable.
195186
196-<figure>
197-<img src="Anchordocking_miniide1.png" title="Anchordocking_miniide1.png" />
198-<figcaption>Anchordocking_miniide1.png</figcaption>
199-</figure>
187+![](/wiki-images/a/a5/Anchordocking_miniide1.png)
200188
201189### Making the main form a dock site
202190
203191In the TMainIDE.FormCreate the main form **MainIDE** is turned into a docksite:
204192
205193``` pascal
206194DockMaster.MakeDockSite(Self,[akBottom],admrpChild);
207195```
208196
209197The parameter *\[akBottom\]* allows to dock other sites at the bottom of MainIDE. The parameter *admrpChild* tells the DockMaster that when the MainIDE is enlarged the extra space is distributed to the docked sites.
210198
211199When the user docks a site to the bottom of MainIDE the site is put onto MainIDE (Site.Parent:=MainIDE) with Site.Align=alBottom. The other controls on MainIDE must be compatible to this. MainIDE for example has a BtnPanel with Align=alLeft and a TNoteBook with Align=alClient. See [[Autosize / Layout|here]] how Align works.
212200
213201The DockMaster adds automatically a splitter:
214202
215-<figure>
216-<img src="Anchordocking_miniide_dockedse1.png" title="Anchordocking_miniide_dockedse1.png" />
217-<figcaption>Anchordocking_miniide_dockedse1.png</figcaption>
218-</figure>
203+![](/wiki-images/c/ca/Anchordocking_miniide_dockedse1.png)
219204
220205As soon as a dockable form is docked its caption is shown in the dock header.
221206
222207#### Requirements for a custom dock site
223208
224209As long as nothing is docked into a custom dock site, your form can do everything as a normal form. But when a site is docked to it, some properties and methods need special care:
225210
226211- AutoSize=true may result in an endless loop. Disable it or override DoAutoSize/CalculatePreferredSize and take special care.
227212- Constraints: The DockMaster clears the maximum Constraints and will restore them on undock.
228213- Child controls anchored to the aligned site may overlap. See [[Autosize / Layout|here]] how Align works.
229214- ChildSizing: The spacing properties like LeftRightSpacing, TopBottomSpacing may interfere with the docking layout.
230215
231216### Procedure to create all other forms by name
232217
233218The MainIDE sets the **DockMaster.OnCreateControl** event, to enable the DockMaster to create forms by name. This is needed to restore layouts.
234219
235220``` pascal
236221DockMaster.OnCreateControl:=@DockMasterCreateControl;
237222```
238223
239224``` pascal
240225procedure TMainIDE.DockMasterCreateControl(Sender: TObject; aName: string; var
241226 AControl: TControl; DoDisableAutoSizing: boolean);
242227
243228 procedure CreateForm(Caption: string; NewBounds: TRect);
244229 begin
245230 AControl:=CreateSimpleForm(aName,Caption,NewBounds,DoDisableAutoSizing);
246231 end;
247232
248233begin
249234 // first check if the form already exists
250235 // the LCL Screen has a list of all existing forms.
251236 // Note: Remember that the LCL allows as form names only standard
252237 // pascal identifiers and compares them case insensitive
253238 AControl:=Screen.FindForm(aName);
254239 if AControl<>nil then begin
255240 // if it already exists, just disable autosizing if requested
256241 if DoDisableAutoSizing then
257242 AControl.DisableAutoSizing;
258243 exit;
259244 end;
260245 // if the form does not yet exist, create it
261246 if aName='CodeExplorer' then
262247 CreateForm('Code Explorer',Bounds(700,230,100,250))
263248 ...
264249 else if aName='DebugOutput' then
265250 CreateForm('Debug Output',Bounds(400,400,350,150));
266251end;
267252```
268253
269254Creating a form can be as simple as this:
270255
271256``` pascal
272257MyForm:=TMyForm.Create(Self);
273258if DoDisableAutoSizing then
274259 MyForm.DisableAutoSizing;
275260```
276261
277262But of course you can put there all kind of initialization code.
278263
279264The *DisableAutoSizing* reduces flickering. Make sure your forms **Visible** property is set to **false**.
280265
281266Remember to call **DisableAutoSizing** for the form if the parameter **DoDisableAutoSizing** is set to *true*, because *Disable-* and *EnableAutosizing* calls must be balanced. If you miss the *DisableAutosizing*, the LCL will raise an exception later:
282267
283268`TControl.EnableAutoSizing SourceEditor1:TSimpleForm: missing DisableAutoSizing`
284269
285-<figure>
286-<img src="MissingDisableAutoSizing.png" title="MissingDisableAutoSizing.png" />
287-<figcaption>MissingDisableAutoSizing.png</figcaption>
288-</figure>
270+![](/wiki-images/8/8e/MissingDisableAutoSizing.png)
289271
290272If you call **DisableAutoSizing** too much, your forms will not appear and/or not resize properly as the LCL is waiting for the *EnableAutoSizing* call that never comes.
291273
292274### Showing forms
293275
294276When a form should be shown, you have probably used something like *'MyForm.Show*. Instead you should now use
295277
296278``` pascal
297279DockMaster.MakeDockable(MyForm);
298280```
299281
300282This will wrap MyForm in a dock site and show it. It is clever enough to figure out if the form is already wrapped in a dock site.
301283
302284If you set the **DockMaster.OnCreateControl** event you can use this:
303285
304286``` pascal
305287DockMaster.ShowControl('MyForm',true);
306288```
307289
308290### Docking manually, via code
309291
310292Use the procedure **DockMaster.ManualDock** to dock a site to or into another.
311293
312294``` pascal
313295procedure ManualDock(SrcSite, TargetSite: TAnchorDockHostSite; Align: TAlign; TargetControl: TControl = nil);
314296```
315297
316298- **SrcSite** is the site to be docked. If SrcSite was docked it will be undocked first.
317299- **TargetSite** is the site where SrcSite will be docked into or docked as neighbor.
318300- **TargetControl** specifies if docking as neighbor (=nil), as inside neighbor (=TargetSide) or in front of a page (=a TAnchorDockPage).
319301
320302### Undocking manually, via code
321303
322304Use the procedure **DockMaster.ManualFloat** to undock a site from its neighbors and create a flotaing top level form. The embedded control stays embedded into a TAnchorDockHostSite.
323305
324306``` pascal
325307procedure ManualFloat(AControl: TControl);
326308```
327309
328310You can give as parameter a TAnchorDockHostSite or a control embedded into a TAnchorDockHostSite (for example a form made dockable with MakeDockable). The site will be put at the same screen location.
329311
330312### Save layout
331313
332314The DockMaster allows to save the current layout to a TConfigStorage. The miniide example uses the xml version:
333315
334316``` pascal
335317procedure TMainIDE.SaveLayout(Filename: string);
336318var
337319 XMLConfig: TXMLConfigStorage;
338320begin
339321 try
340322 // create a new xml config file
341323 XMLConfig:=TXMLConfigStorage.Create(Filename,false);
342324 try
343325 // save the current layout of all forms
344326 DockMaster.SaveLayoutToConfig(XMLConfig);
345327 XMLConfig.WriteToDisk;
346328 finally
347329 XMLConfig.Free;
348330 end;
349331 except
350332 on E: Exception do begin
351333 MessageDlg('Error',
352334 'Error saving layout to file '+Filename+':'#13+E.Message,mtError,
353335 [mbCancel],0);
354336 end;
355337 end;
356338end;
357339```
358340
359341### Load layout
360342
361343``` pascal
362344procedure TMainIDE.LoadLayout(Filename: string);
363345var
364346 XMLConfig: TXMLConfigStorage;
365347begin
366348 try
367349 // load the xml config file
368350 XMLConfig:=TXMLConfigStorage.Create(Filename,True);
369351 try
370352 // restore the layout
371353 // this will close unneeded forms and call OnCreateControl for all needed
372354 DockMaster.LoadLayoutFromConfig(XMLConfig);
373355 finally
374356 XMLConfig.Free;
375357 end;
376358 except
377359 on E: Exception do begin
378360 MessageDlg('Error',
379361 'Error loading layout from file '+Filename+':'#13+E.Message,mtError,
380362 [mbCancel],0);
381363 end;
382364 end;
383365end;
384366```
385367
386368### Enlarge/Shrink
387369
388370The anchor docking manager can enlarge/shrink docked neighbors. This is done via the popup menu of the dock header or in code with the function **DockMaster.ManualEnlarge**:
389371
390372``` pascal
391373function ManualEnlarge(Site: TAnchorDockHostSite; Side: TAnchorKind; OnlyCheckIfPossible: boolean): boolean;
392374```
393375
394376Site is a child site, Side the side of Site to expand. If you only want to test if enlarge is possible set OnlyCheckIfPossible to true.
395377
396378### Enlarge one, shrink another
397379
398380Shrink neighbor *Object Inspector*, enlarge *Messages*: Right click on the header of *Messages* and click on **Enlarge right side**. Two splitters are resized.
399381
400382![](/wiki-images/1/15/Anchordocking_before_enlarge1.png) enlarging *Messages* to the right side: ![](/wiki-images/f/f8/Anchordocking_after_enlarge1.png)
401383
402384### Enlarge one, shrink many
403385
404386Shrink splitter at one side, enlarge both neighbor splitters, rotate the splitter behind, enlarge Control, shrink controls at rotate splitter. Right click on header of *Source Editor 1* then click on **Enlarge bottom side**.
405387
406388![](/wiki-images/c/cb/Anchordocking_before_enlarge2.png) becomes ![](/wiki-images/4/42/Anchordocking_after_enlarge2.png)
407389
408390### General docking options
409391
410392The AnchorDocking package provides a dialog to setup some of the properties of the DockMaster. The dialog is in the unit AnchorDockOptionsDlg and you can use it simply:
411393
412394``` pascal
413395uses ... AnchorDockOptionsDlg;
414396...
415397procedure TMainIDE.FormCreate(Sender: TObject);
416398...
417399begin
418400 ...
419401 DockMaster.OnShowOptions:=@ShowAnchorDockOptions;
420402 ...
421403end;
422404```
423405
424406This will add a new menu item to the popup menus of the dock headers and pages called *Docking options*.
425407
426408## Why use Anchors instead of Align?
427409
428410Anchors allow to create any possible rectangular layout. Align is limited. Align with Panels can theoretically create a lot of layouts, but still not all. And some operations like enlarge/shrink are more complicated using Align/Panels than using Anchors. Align works good for a few forms, but the more forms are docked, the more the disadvantages of Align become visible.
429411
430412### Layouts that can be created with Align
431413
432414Align can only create the following layouts:
433415
434-<figure>
435-<img src="Anchordocking_align_layout1.png" title="Anchordocking_align_layout1.png" />
436-<figcaption>Anchordocking_align_layout1.png</figcaption>
437-</figure>
416+![](/wiki-images/1/13/Anchordocking_align_layout1.png)
438417
439418The alTop controls are always at the top, filling the whole horizontal width. That's because the LCL first aligns all controls with alTop, then all alBottom, then alLeft, then alRight and finally alClient.
440419
441420### Layouts that can be created with Align and Panels
442421
443422It is possible to nest Align layouts by using hidden panels. Then any layout that can be recursively splitted in halves can be created. Then you can create for example:
444423
445-<figure>
446-<img src="Anchordocking_align_panels_layout1.png" title="Anchordocking_align_panels_layout1.png" />
447-<figcaption>Anchordocking_align_panels_layout1.png</figcaption>
448-</figure>
424+![](/wiki-images/0/0e/Anchordocking_align_panels_layout1.png)
449425
450426This requires only one hidden panel.
451427
452428### Changing Layouts
453429
454430Now the user wants to enlarge the *FPDocEditor* horizontally (and shrink *CodeExplorer*). With the *AnchorDocking* you can simply right click on the *FPDocEditor* header and click **Enlarge right side**.
455431
456-<figure>
457-<img src="Anchordocking_align_panels_layout2.png" title="Anchordocking_align_panels_layout2.png" />
458-<figcaption>Anchordocking_align_panels_layout2.png</figcaption>
459-</figure>
432+![](/wiki-images/8/88/Anchordocking_align_panels_layout2.png)
460433
461434Other docking engines need at least 2 panels. One for *SrcEditor*,*Messages*,*FPDocEdit*,*CodeExpl* and one for *SrcEdit* and *Messages*. Most docking layouters do not even provide a simple way to change the layout in this way. An algorithm to allow this layout change, must analyze the whole structure as if there were no panels and must reparent a lot of things. Basically the algorithm must do the same as the anchor docking algorithm, but with the extra work of translating the layout into Align plus hidden panels.
462435
463436### Layouts that are impossible with Align and Panels
464437
465438Now the user wants to enlarge *SourceEditor1* horizontally (and shrink *ObjectInspector*):
466439
467-<figure>
468-<img src="Anchordocking_impossible_with_align_panels1.png" title="Anchordocking_impossible_with_align_panels1.png" />
469-<figcaption>Anchordocking_impossible_with_align_panels1.png</figcaption>
470-</figure>
440+![](/wiki-images/e/e9/Anchordocking_impossible_with_align_panels1.png)
471441
472442This layout is impossible with Align and panels, because you can not cut it in two halves. The same with
473443
474-<figure>
475-<img src="Anchordocking_impossible_with_align_panels2.png" title="Anchordocking_impossible_with_align_panels2.png" />
476-<figcaption>Anchordocking_impossible_with_align_panels2.png</figcaption>
477-</figure>
444+![](/wiki-images/1/1e/Anchordocking_impossible_with_align_panels2.png)
478445
479446### Conclusion
480447
481448Align with hidden panels allows you to easily create a simple docking manager that works well for a few forms, but it will always limit the user. Align is useful for row and column layouts, not for tables. Anchor docking works even for complex forms.
482449
483450## Old/deprecated anchor docking
484451
485452### Create a TLazDockingManager
486453
487454``` pascal
488455 DockingManager:=TLazDockingManager.Create(Self);
489456```
490457
491458The Self as parameter is only used as Owner. That means, when the mainform is freed, the DockingManager is freed too. You can use *nil* and free the DockingManager yourself.
492459
493460### Optional: Loading a configuration
494461
495462You can load the user configuration from disk.
496463
497464``` pascal
498465 Config:=TXMLConfigStorage.Create('config.xml',true);
499466 DockingManager.LoadFromConfig(Config);
500467 Config.Free;
501468```
502469
503470This loads the file *config.xml*. The config can be created by the SaveToConfig function. See below.
504471
505472### Make a form/control dockable
506473
507474Create a TLazControlDocker for each form/control that should be dockable
508475
509476``` pascal
510477 ControlDocker1:=TLazControlDocker.Create(Self);
511478 ControlDocker1.Name:='DockerForm1';
512479 ControlDocker1.Manager:=DockingManager;
513480```
514481
515482### Optional: Saving the user configuration to disk
516483
517484When the program is closed you can save the user configuration to disk
518485
519486``` pascal
520487 Config:=TXMLConfigStorage.Create('config.xml',true);
521488 DockingManager.SaveToConfig(Config);
522489 Config.WriteToDisk;
523490 Config.Free;
524491```
525492
526493## See also
527494
528495- [[AnchorDockingDsgn]] AnchorDocking in the Lazarus IDE
529496- [[Anchor Docking Step by step example|Anchor Docking: A Step by step example]]
530497- [[Docking]] in general
531498- [[EasyDockingManager]] - an alternative docking implementation with a simpler layout engine and fewer options.
532499
533500---
534501*From the Free Pascal wiki, page "Anchor Docking", as it stood on 2024-01-27 after a change by Rich2014, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
535502Category: Docking
536503Category: Lazarus IDE plugins

Back to history