Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » Tool program to get default values from registry Collapse All
Subject Author Date
Wilhelm Falkner Sep 1, 2006 - 3:46 AM

I have a Framewindow, with a lot of CExtControlBar with CExtResizableDialog inside. In the ..::OnCreate I create all these bars and dialogs, use SetInitDesiredSizeVertical, SetInitDesiredSizeHorizontal, EnableDocking, DockControlBar and DockControlBarIntoTabbedContainer. It is very hard to find right values and positions. So my plan: Use any default values, start the programm, position all bars, set size. Stop the programm. Now extracting from your registry settings, how to set all values right. Maybe a little tool prog can help creating the C++ code. For sure, this help prog. do not know the names of my variables, but how about use enumerated? Do you think, this would be possible?
TIA
Willi

Technical Support Sep 3, 2006 - 11:33 AM

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.

Wilhelm Falkner Sep 4, 2006 - 1:33 AM

Thanks, this can be a possible way. The remaining problem is, that a lot of our customer are normal useres, that mean, they are not allowed to run RegEdit and RegEdit is protected in a way, that they can’t start it. Any other hint?
TIA
Willi

Suhai Gyorgy Sep 4, 2006 - 2:04 AM

You misunderstood Support. Their approach is: you, as program designer, save the controlbar settings from YOUR computer’s registry into a file called MyBarState.reg. And when you make installation package for your application, you configure the installer to use that MyBarState.reg file and save its content to the registry of the computer where the installation takes place. So customers won’t have to run RegEdit, installer will modify registry.

But you, as the program designer, can test to see if controlbar state saved in MyBarState.reg works as desired: for testing porpuses you call RegEdit MyBarState.reg command on a clean computer and after that run program to see what state was saved to the registry.

Wilhelm Falkner Sep 4, 2006 - 4:42 AM

Sorry, but you do not understand the problem: Customers without rights are not allowed to use RegEdit to INCLUDE MyBarState.reg into the registry. Installer and programm are allowed to write to HKEY_CURRENT_USER, but RegEdit to include same *.reg files is disabled. Our customers are in an very sensitiv area, so their accounts are terrible restricted: No write to any windows folders, even we are not allowed to use deinstall programms

Technical Support Sep 4, 2006 - 11:45 AM

You can use a file on a disk instead of the registry. The StateInFile sample demonstrates how to do this.

Wilhelm Falkner Sep 4, 2006 - 12:54 PM

Thanks, this should work

Suhai Gyorgy Sep 4, 2006 - 6:14 AM

Sorry, my mistake.

Wilhelm Falkner Sep 2, 2006 - 5:25 AM

I would need this feature, because it seems to be impossible, that the install-prog at customer side create all your registry values, so usefull defaults has to be inside code