How to set the exact initial positions of docked control bars when the application starts for the first time?

Professional User Interface Suite, Copyright FOSS Software Inc. Help Published with Permission.

When your application starts for the first time, you should specify the initial layout of your dockable windows. Each time it starts after that, the layout, which may have been changed by the user during the first run, will be read from the registry or a file. So you need to set the initial layout in some way.

You can use the CExtControlBar::DockControlBarInnerOuter() and CExtControlBar::DockControlBarLTRB() methods to dock control bars to the frame window and relative to each other. This is described in this article. You can also use the CExtControlBar::SetInitDesiredSizeHorizontal() and CExtControlBar::SetInitDesiredSizeVertical() methods to specify their size. However, if you have a complex layout, it is not always possible to guaranty that the size of control bars will be exactly as you specified in the above two methods. The reason for this is that the size and position of a control bar can be affected by the neighboring control bars.

The alternative approach is to specify the initial layout by reading the layout information from the registry or a file even if the application starts for the first time. Here is how you can do this:

1) Run your application. The size and position of control bars do not matter.

2) Using the mouse, dock and resize control bars in order to get the layout you need.

3) Exit the application. The UI state is now serialized to the registry or in a file.

4) Include the registry information or the file in the installer of your application.

5) When your application starts for the first time, do not dock the control bars programmatically but rather load and initialize the layout with the serialized data from the registry or the file.