Click here to Skip to main content
Click here to Skip to main content

MFC Smart Frames

, 23 May 2002
Rate this:
Please Sign up or sign in to vote.
Save window sizes, positions and state for all frames in an MDI MFC Application
<!-- Download Links --> <!-- Add the rest of your HTML here -->

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
We need to develop some good software for the brain.

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 24 May 2002
Article Copyright 2002 by [James Pullicino]
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid