Click here to Skip to main content
11,720,374 members (79,332 online)
Click here to Skip to main content
Add your own
alternative version

Child Dialog (Sub Forms)

, 17 Nov 1999 120.5K 3.3K 46
A simple class for handling Child Dialogs within a dialog or property sheet.
//  Project     : any
//  Compiler    : Visual C++ 6.0
//  Plattform   : Windows 95/NT
//  File        : SubFormCollection.h
//  Programmer  : D. Zuppinger, SoftToys
//  Copyright   : public domain
//  Contact     : daniel@softtoys.com
//  Description : class for simple support of sub forms within dialogs
//  History     : October 1999, initial version

//#### This is the class, supporting an easy handling of sub forms
//#### IMPORTANT:
// Dialogs must be defined with the following properties:
//      Style : Child
//      Border: thin or none
//      Control: ticked


#if !defined(AFX_SUBFORMCOLLECTION_H__EEF10080_9028_11D3_8594_00105A744766__INCLUDED_)
#define AFX_SUBFORMCOLLECTION_H__EEF10080_9028_11D3_8594_00105A744766__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <afxtempl.h>
#include "stdafx.h"

class CSubFormCollection  
{
public:
	CSubFormCollection();
	virtual ~CSubFormCollection();

    bool SetActive(int ix);   // set and display an other sub form
    
    bool CreateSubForm(UINT id,CWnd* pParentWnd);
        // create a subform with a given resource template
    
    bool ShowSubForm(int ix = -1);
        // display the requested subform (by default the active form is displayed)
    
    void SetRelPos(const CRect& rect) {m_Rect = rect;m_bCentered = false;};
        // set the relative position of the subforms
    
    void SetCenterPos(const CRect& rect) {m_Rect = rect;m_bCentered = true;};
        // set the position of the subforms and switch the center mode on

protected:
    CArray<CDialog*, CDialog*> m_Forms; // array with all forms
    int m_nActiveForm;  // index to the currently active sub form
    CRect m_Rect;       // position of the sub form
    bool m_bCentered;   // true if the form is centred within the rect, else false

    int AddForm(CDialog* dlg) { return(m_Forms.Add(dlg));}; // internal method for adding a newly created form
};

#endif // !defined(AFX_SUBFORMCOLLECTION_H__EEF10080_9028_11D3_8594_00105A744766__INCLUDED_)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

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

Share

About the Author

Daniel Zuppinger
Chief Technology Officer
Switzerland Switzerland
Professional IT developer since 1983. First projects with Cobol, then Pascal, Modula2, C and since Visual C++ 1.0 also with C++. Works since 1986 as Consultant, between 1990 and 2008 for Infobrain in Switzerland, currently employed by enValue (also Switzerland).
Current field is the project management and development of software for Bank applications.
Married, two daughters, Hobbies : Paragliding, Orienteering, Mountainbiking, Photography

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150901.1 | Last Updated 18 Nov 1999
Article Copyright 1999 by Daniel Zuppinger
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid