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

Layout Manager for Dialogs, Formviews, DialogBars and PropertyPages

, 4 Aug 2000
A framework to provide automatic layout control for dialogs and forms
// MyDialog.cpp: Implementierungsdatei
//

#include "stdafx.h"
#include "LayoutManager.h"
#include "MyDialog.h"

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

/////////////////////////////////////////////////////////////////////////////
// Dialogfeld CMyDialog 


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


void CMyDialog::DoDataExchange(CDataExchange* pDX)
{
	ETSLayoutDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMyDialog)
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CMyDialog, ETSLayoutDialog)
	//{{AFX_MSG_MAP(CMyDialog)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// Behandlungsroutinen f�r Nachrichten CMyDialog 

BOOL CMyDialog::OnInitDialog() 
{
	ETSLayoutDialog::OnInitDialog();
	
	/* DialogMgr: Add this: */
	// See article for comments

	// define the Layout

	// Possibility 1
	CreateRoot(VERTICAL)
		<< item ( IDC_NEW_ITEM_STATIC, NORESIZE )

		<< 	( pane(HORIZONTAL, ABSOLUTE_VERT )
			<< item( IDC_NEW_ITEM, GREEDY )
			<< item( IDC_ADD_ITEM, NORESIZE )
			)

		<< item ( IDC_ITEM_LIST_STATIC, NORESIZE )
		<< item ( IDC_ITEM_LIST, GREEDY )
	
		<<	( pane(HORIZONTAL, ABSOLUTE_VERT )
			<< item( IDOK, RELATIVE_HORZ, 70 )
			<< item( IDCANCEL, RELATIVE_HORZ, 30 )
			);
	
	UpdateLayout();

/*
	// Possibility 2
	CPane newItemPane=new Pane ( this, HORIZONTAL );

	newItemPane->addItem ( IDC_NEW_ITEM, GREEDY );
	newItemPane->addItem ( IDC_ADD_ITEM, NORESIZE );


	CPane bottomPane=new Pane ( this, HORIZONTAL );
	bottomPane->addItem ( paneNull, GREEDY );
	bottomPane->addItem ( IDOK, NORESIZE );
	bottomPane->addItem ( IDCANCEL, NORESIZE );

	CreateRoot( VERTICAL );

	m_RootPane->addItem ( IDC_NEW_ITEM_STATIC, NORESIZE );
	m_RootPane->addPane ( newItemPane, ABSOLUTE_VERT );
	m_RootPane->addItem ( IDC_ITEM_LIST_STATIC, NORESIZE );
	m_RootPane->addItem ( IDC_ITEM_LIST, GREEDY );
	m_RootPane->addPane ( bottomPane, ABSOLUTE_VERT );

	UpdateLayout();
/*

/*
	// Possibility 3
	UpdateLayout (
		
		paneVert()
			<< item ( IDC_NEW_ITEM_STATIC, NORESIZE )

			<< 	( pane(HORIZONTAL, ABSOLUTE_VERT )
				<< item( IDC_NEW_ITEM, GREEDY )
				<< item( IDC_ADD_ITEM, NORESIZE )
				)

			<< item ( IDC_ITEM_LIST_STATIC, NORESIZE )
			<< item ( IDC_ITEM_LIST, GREEDY )
		
			<<	( pane(HORIZONTAL, ABSOLUTE_VERT )
				<< item( paneNull, GREEDY )
				<< item( IDOK, NORESIZE )
				<< item( IDCANCEL, NORESIZE )
				);

	);
*/
	/************************/
	


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





// Only horizontally sizable
////////////////////////////

/////////////////////////////////////////////////////////////////////////////
// Dialogfeld CMyDialogHorz 


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


void CMyDialogHorz::DoDataExchange(CDataExchange* pDX)
{
	ETSLayoutDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMyDialogHorz)
		// HINWEIS: Der Klassen-Assistent f�gt hier DDX- und DDV-Aufrufe ein
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CMyDialogHorz, ETSLayoutDialog)
	//{{AFX_MSG_MAP(CMyDialogHorz)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// Behandlungsroutinen f�r Nachrichten CMyDialogHorz 

BOOL CMyDialogHorz::OnInitDialog() 
{
	ETSLayoutDialog::OnInitDialog();
	
	/* DialogMgr: Add this: */
	// See article for comments

	// define the Layout
	CPane newItemPane = pane( HORIZONTAL, ABSOLUTE_VERT )
		<< item( IDC_NEW_ITEM, GREEDY )
		<< item( IDC_ADD_ITEM, NORESIZE );


	CPane bottomPane = pane ( HORIZONTAL, ABSOLUTE_VERT )
		<< itemGrowing(HORIZONTAL)
		<< item( IDOK, NORESIZE )
		<< item( IDCANCEL, NORESIZE );

	CreateRoot( VERTICAL )
		<< item( IDC_NEW_ITEM_STATIC, NORESIZE )
		<< newItemPane
		<< item( IDC_ITEM_LIST_STATIC, NORESIZE )
	
		// This line is the difference to CMyDialog !!!
		<< item( IDC_ITEM_LIST, ABSOLUTE_VERT )

		<< bottomPane;

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





// Only vertically sizable
////////////////////////////

/////////////////////////////////////////////////////////////////////////////
// Dialogfeld CMyDialogVert 


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


void CMyDialogVert::DoDataExchange(CDataExchange* pDX)
{
	ETSLayoutDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMyDialogVert)
		// HINWEIS: Der Klassen-Assistent f�gt hier DDX- und DDV-Aufrufe ein
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CMyDialogVert, ETSLayoutDialog)
	//{{AFX_MSG_MAP(CMyDialogVert)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// Behandlungsroutinen f�r Nachrichten CMyDialogVert 

BOOL CMyDialogVert::OnInitDialog() 
{
	ETSLayoutDialog::OnInitDialog();
	
	/* DialogMgr: Add this: */
	// See article for comments

	// define the Layout
	CPane newItemPane = pane( HORIZONTAL, ABSOLUTE_VERT )

		// This line is different from CMyDialog !!!
		<< item( IDC_NEW_ITEM, ABSOLUTE_HORZ )
		<< item( IDC_ADD_ITEM, NORESIZE );


	CPane bottomPane = pane ( HORIZONTAL, ABSOLUTE_VERT )
	
		// This line is different from CMyDialog !!!
		<< item( paneNull, ALIGN_FILL_HORZ | ABSOLUTE_HORZ)
		<< item( IDOK, NORESIZE )
		<< item( IDCANCEL, NORESIZE );

	CreateRoot( VERTICAL )
		<< item( IDC_NEW_ITEM_STATIC, NORESIZE )
		<< newItemPane
		<< item( IDC_ITEM_LIST_STATIC, NORESIZE )
	
		// This line is the difference to CMyDialog !!!
		<< item( IDC_ITEM_LIST, ABSOLUTE_HORZ )

		<< bottomPane;

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

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

Erwin Tratar
Web Developer
Germany Germany
independant software developer from Germany.
author of Euraconf, an isdn/pabx management software
 
Programmer since 1991, c/c++/java, started with professional games development, now mainly network, telecommunication and internet stuff

| Advertise | Privacy | Mobile
Web03 | 2.8.140922.1 | Last Updated 5 Aug 2000
Article Copyright 1999 by Erwin Tratar
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid