multiwnd.gifThe idea behind the CMultiWnd class library is really simple: I wanted to have multiple dialog-style subwindows within an MDI child window in an MDI MFC application. I wanted these subwindows to behave much the same way as MDI child windows do; I wanted them to show their activated state by highlighting their title bar, I wanted them to respond to the TAB key, and I wanted them to interact with their parent's (that is, the MDI child window's) scroll bars.

The solution is presented in the form of a pair of window classes, CMultiForm and CSubForm. CMultiForm is a class derived from the MFC class CFormView; CSubForm is derived from CDialog.

To make use of these classes, you would create an MFC application in which your view is derived originally from CFormView, and then replace all references to CFormView with CMultiForm. The subwindows are created as CDialog-derived dialog windows; afterwards, references to CDialog must be replaced with CSubForm. Some additional magic is required to ensure correct behavior; the view class's OnInitialUpdate and OnClose member functions must be modified, as well as the OnNcActivate and OnDestroy member functions of the child frame class.

All of this is demonstrated by a comprehensive example program that is shown to the right here. No matter which license option you choose, you will receive a copy of the full source of this programming example.

CMultiForm Class Members

In addition to some CWnd member function overrides that implement its unique functionality, the CMultiForm class has the following public members:

Data Members

m_bSaveSettings Controls automatic save behavior.

Operations

LoadRectFromRegistry Loads size and position information.
SaveRectToRegistry Saves size and position information.
OnWindowSavesettingsnow Saves size and position information.

static bool m_bSaveSettings

Remarks
This static member variable controls the global behavior of CMultiForm and CSubForm objects. When set to true, CMultiForm and CSubForm windows will save their current state when their OnClose member function is called.


void ResetScrollSizes()

Remarks
Call this member function after creating any CSubForm-derived child windows. This function will adjust the scrollbars of the CMultiForm object to reflect the current position of its descendants.


void LoadRectFromRegistry(CString &strKey, bool bLoadSubforms = true)

Parameters  
strKey The name of a subkey under HKEY_CURRENT_USER.
bLoadSubforms If set, size and position information for CSubForm-derived members will also be loaded.

Remarks
This member function loads window position and state information from the Registry, using the key name specified by strKey. This must be a valid key name under HKEY_CURRENT_USER.


void SaveRectToRegistry(const CString *pstrKey = NULL, bool bSaveSubforms = false)

Parameters  
pstrKey The name of a subkey under HKEY_CURRENT_USER.
bSaveSubforms If set, size and position information for CSubForm-derived members will also be saved.

Remarks
This member function saves window state and position information to the Registry. If pstrKey is NULL, the key previously specified by a call to LoadRectFromRegistry will be used.


afx_msg void OnWindowSavesettingsnow()

Remarks
This member function saves current window size and position information. In the base implementation, it is called in response to the ID_WINDOW_SAVESETTINGSNOW command.


CSubForm Class Members

The CSubForm class has the following unique public member functions:

Operations

ToggleVisible Shows or hides the window.
LoadRectFromRegistry Loads size and position information.
SaveRectToRegistry Saves size and position information.
OnSetfocusTab Facilitates the use of a tab control.

void ToggleVisible()

Remarks
This member function shows or hides the window.


void LoadRectFromRegistry(const CString &strKey)

Parameters  
strKey The name of a subkey under HKEY_CURRENT_USER.

Remarks
This member function loads window position and state information from the Registry, using the key name specified by strKey. This must be a valid key name under HKEY_CURRENT_USER.


void SaveRectToRegistry(const CString *pstrKey = NULL)

Parameters  
pstrKey The name of a subkey under HKEY_CURRENT_USER.

Remarks
This member function saves window state and position information to the Registry. If pstrKey is NULL, the key previously specified by a call to LoadRectFromRegistry will be used.


afx_msg void OnSetfocusTab()

Remarks
This member function facilitates the use of a tab control inside a CSubForm-derived window. In the base implementation, it is called whenever a control with identifier IDC_TAB receives the window focus.


A license to use the CMultiWnd class library in your application can be purchased online here. When you place an order, a copy of the CMultiWnd DLL, header and library files, and sample code will be e-mailed to you, usually within 24 hours. If you purchase an unrestricted license, you will also receive a copy of the CMultiWnd source code.

License type

Price in USD

Buy Now!
Single Developer License
Authorizes a single developer to use the library in his or her projects, and redistribute the DLL to end-users. No source code is included.
$20.00

Site License
Authorizes a group of developers working together at the same geographic location to use the library in their projects, and redistribute the DLL to end-users. No source code is incldued.
$100.00

Unrestricted License
Provides a non-exclusive license to do as you please with the library. Includes the license to modify the library, redistribute the library in source or object form, or incorporate the library or any parts thereof into your projects. Source code included.
$600.00