Click here to Skip to main content
Licence 
First Posted 23 May 2002
Views 50,520
Bookmarked 17 times

MFC Smart Frames

By | 23 May 2002 | Article
Save window sizes, positions and state for all frames in an MDI MFC Application

Introduction to Smart Frames for MFC

Smart Frames are a set of MFC Classes which implement the following functionality:

  • Saving and restoring window state of CMDIFrameWnd derived classes;
  • Saving and restoring window state of CMDIChildWnd derived classes.
The Smart Frame classes do NOT offer the following functionality:
  • Saving and restoring toolbar states;
  • Saving and restoring SDI frames and child frames.
If these functions are ever implemented this article will be updated with the changes.

Programming Tasks

To implement Smart Frames in your MFC MDI Applications follow these steps:

Notes on deriving from CSMDIFrameWnd and CSMDIChildWnd

The easiest way to derive from these classes is to create your mainframe and childframes using the MFC Class Wizard or MFC App Wizard as you normally would and then following these steps. Please note that these are only suggestions:

  • Include SMDIFrameWnd.h and SMDIChildWnd.h in stdafx.h;
  • Change the derivation of your mainframe class from CMDIFrameWnd to CSMDIFrameWnd;
  • Change all references to CMDIFrameWnd to CSMDIFrameWnd in your mainframe implementation;
  • Change the derivation of your child frame class from CMDIChildWnd to CSMDIChildWnd;
  • Change all references to CMDIChildWnd to CSMDIChildWnd in your child frame implementation(s);

How do Smart Frames work?

To persist and restore frame states I use techniques described in another article which I submitted to Code Project some time ago. Here is the link: Saving a windows size position and state in MFC

The Smart Frames CPP and H files

Smart Frames consist of the following CPP and H files:

  • SMDIFrameWnd.h and SMDIFrameWnd.cpp (CSMDIFrameWnd)
  • SMDIChildWnd.h and SMDIChildWnd.cpp (CSMDIChildWnd)

The Smart Frames Classes

Smart Frames are implemented in the following classes:

  • CSMDIFrameWnd
  • CSMDIChildWnd

The Smart Frames Demo Project

Included with this article is a Demo Project which is a bare-bones implementation of Smart Frames. It was created and tested with Visual Studio Version 6.

Happy Coding!

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

[James Pullicino]

Web Developer

United Kingdom United Kingdom

Member

We need to develop some good software for the brain.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
-- There are no messages in this forum --
Permalink | Advertise | Privacy | Mobile
Web03 | 2.5.120517.1 | Last Updated 24 May 2002
Article Copyright 2002 by [James Pullicino]
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid