We would offer you the following solution. You cannot skip the step of specifying the initial control bar’s layout programmatically because otherwise you would have had an invalid layout and unusable control bars. But you can dock them roughly and then make necessary fine adjustments by running the application and saving the final settings to the registry. Here are the steps to follow:
1) Dock control bars programmatically in some preliminary way:
if( ! CExtControlBar::ProfileBarStateLoad(
this,
pApp->m_pszRegistryKey,
pApp->m_pszProfileName,
pApp->m_pszProfileName,
&m_dataFrameWP
)
)
{
DockControlBar( &m_wndMenuBar );
DockControlBar( &m_wndToolBar1 );
DockControlBar( &m_wndToolBar2 );
. . .
DockControlBar( &m_wndToolBarN );
m_wndResizableBar0.DockControlBar(AFX_IDW_DOCKBAR_LEFT, 1, this, false );
m_wndResizableBar1.DockControlBar(AFX_IDW_DOCKBAR_LEFT, 1, this, false );
. . .
m_wndResizableBarN.DockControlBar(AFX_IDW_DOCKBAR_LEFT, 1, this, false );
RecalcLayout();
}
This code means that if the application’s GUI state cannot be read from the registry, the layout of control bars is set programmatically.
2) Run the application and make the desired initial layout by putting each control bar in the desired adjusted position. Close the application. The adjusted settings are now in the registry under the
HKEY_CURRENT_USER\Software\Foss\MDI\ProfUIS254\Profiles\MDI\ControlBar (For illustration purposes, we will use
Foss as the company name and
MDI as the application name here).
3) Run the
RegEdit tool from the command line, invoke the context menu for the
HKEY_CURRENT_USER\Software\Foss\MDI\ProfUIS254\Profiles\MDI\ControlBar tree item and export the settings under this key by clicking the
Export menu item. For example, save the settings into the
C:\MyBarState.Reg file. This file now contains the UI state for the
MDI sample.
4) If you run the following command on another clean computer
RegEdit MyBarState.Reg and run your application after that, you will see that you have the very same, desired layout. You can configure your installer in a way so it modifies the registry to apply the settings stored in the
MyBarState.Reg file.
You cannot skip step 1 because otherwise you would not have been able to rearrange control bars in the desired way.
The word
Foss in the registry key path is the value taken from
::AfxGetApp()->m_pszRegistryKey
and it is typically the company’s name. The word
MDI in the registry key path is the value taken from
::AfxGetApp()->m_pszProfileName
and it is typically the software product’s name.