Saving the layout of a CFrameWndEx app ?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: Saving the layout of a CFrameWndEx app ?

  1. #1
    Join Date
    May 2002
    Posts
    1,726

    Saving the layout of a CFrameWndEx app ?

    If you examine the Registry entry for an application that uses a CMainFrame class derived from CFrameWndEx, you will find an entry entitled 'Workspace' which contains (I think) numerous entries releating to the last layout configuration.

    I have seen applications that offer the user an option of 'Save Layout'. Is there a simple, direct way to do this ?
    mpliam

  2. #2
    Join Date
    May 1999
    Location
    DELAWARE, USA
    Posts
    9,915

    Re: Saving the layout of a CFrameWndEx app ?

    It depends how you define "save layout".

    This is actually done by WinAppEx::LoadState called from CFrameImpl::OnLoadFrame. It reads various states from Workspace registry.

    It is done without giving user any choice. If you want to use default implementation and give user a choice, override CFrameWndEx::LoadFrame.

    You can also use LoadCustomState override to load custom states. This is called from WinAppEx::LoadState.

    You can save custom state using SaveCustomState override called from CWinAppEx::OnClosingMainFrame, initiated from CFrameWndEx::OnClose

    Both, LoadCustomState and SaveCustomState are inserted by the app wizard when application is created. They are empty, ready for inserting custom code.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  3. #3
    Join Date
    May 2002
    Posts
    1,726

    Re: Saving the layout of a CFrameWndEx app ?

    Thanks John. My question was poorly thought out but your answer provided me with exactly what I was looking for. I really want a new user who installs the app on his machine to at first boot up a default layout. How best to do that ?
    mpliam

  4. #4
    Join Date
    May 1999
    Location
    DELAWARE, USA
    Posts
    9,915

    Re: Saving the layout of a CFrameWndEx app ?

    This should be quite easy. It is just a matter of saving layout you need to be used as default by running app, arranging layout and exit.
    Get registry values for the workspace key (HKCU.Software.YourString.AppName.Workspace) and have installation program create this key.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  5. #5
    Join Date
    May 2002
    Posts
    1,726

    Re: Saving the layout of a CFrameWndEx app ?

    Yeah. Thanks. I thought of that. But the Workspace registry entries for an app with a bunch of CDockablePane derived windows are alarmingly extensive. I was hoping that there was a easier way. Guess not.

    One possible method would be to :
    1 - Set up the app interface in the layout that you wish to be the default, then exit the app
    2 - Using the Windows Registry Editor, highlight the 'Workspace' folder of the app in HKEY_CURRENT_USERS/... and Right Click->Export and save as Workspace.reg
    3 - Presumably, an installer could use this *.reg file to initialize the default workspace configuration (not sure exactly how - depends upon the installer you're using).

    What do you think ?
    Last edited by Mike Pliam; September 30th, 2011 at 04:14 PM.
    mpliam

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center