Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Child Dialog (Sub Forms)

, 17 Nov 1999
A simple class for handling Child Dialogs within a dialog or property sheet.
// TestDlg.cpp: Implementierungsdatei
//

#include "stdafx.h"
#include "ChildDlgTest.h"
#include "TestDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// Dialogfeld CTestDlg 


CTestDlg::CTestDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CTestDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CTestDlg)
		// HINWEIS: Der Klassen-Assistent f�gt hier Elementinitialisierung ein
	//}}AFX_DATA_INIT
}


void CTestDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CTestDlg)
	DDX_Control(pDX, IDC_COMBO1, m_Combo);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CTestDlg, CDialog)
	//{{AFX_MSG_MAP(CTestDlg)
	ON_WM_SHOWWINDOW()
	ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// Behandlungsroutinen f�r Nachrichten CTestDlg 

BOOL CTestDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Zus�tzliche Initialisierung hier einf�gen

    m_Combo.SetCurSel(0);


    //#### initialize sub forms
    CRect r;
    (GetDlgItem(IDC_SUBFORM_FRAME))->GetWindowRect(&r); // get the position for the subforms
    //    m_SubForms.SetRelPos(r);  // if the positioning is absolute
    m_SubForms.SetCenterPos(r);     // if the subdialog needs to be centered
    m_SubForms.CreateSubForm(IDD_SUBFORM1,this); // create the sub forms
    m_SubForms.CreateSubForm(IDD_SUBFORM2,this);
    m_SubForms.CreateSubForm(IDD_SUBFORM3,this);
    m_SubForms.CreateSubForm(IDD_SUBFORM4,this);
    m_SubForms.ShowSubForm(); // show the first one
    //#### end initialize sub forms


	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX-Eigenschaftenseiten sollten FALSE zur�ckgeben
}


void CTestDlg::OnShowWindow(BOOL bShow, UINT nStatus) 
{
	CDialog::OnShowWindow(bShow, nStatus);
    
    // TODO: Code f�r die Behandlungsroutine f�r Nachrichten hier einf�gen
}


void CTestDlg::OnSelchangeCombo1() 
{
    //#### method to change between sub forms
    //#### here a combobox in the main dialog is used
	m_SubForms.ShowSubForm(((CComboBox*)GetDlgItem(IDC_COMBO1))->GetCurSel());	
}

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

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

| Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 18 Nov 1999
Article Copyright 1999 by Daniel Zuppinger
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid