Click here to Skip to main content
15,892,768 members
Articles / Programming Languages / C++

EasySize - Dialog Resizing in No Time!

Rate me:
Please Sign up or sign in to vote.
4.95/5 (213 votes)
23 Mar 20074 min read 1.1M   27.9K   290  
An easy way to position controls in resizable dialogs or property pages using just a few macros
In this article, you will learn to design your dialog the way you want it to look in the resource editor, and then define how the controls will behave when the dialog is resized using one single macro for each control.
// EasySizeDemoDlg.h : header file
//

#if !defined(AFX_EASYSIZEDEMODLG_H__8E227342_30AC_44D9_B83A_52321DCD07CE__INCLUDED_)
#define AFX_EASYSIZEDEMODLG_H__8E227342_30AC_44D9_B83A_52321DCD07CE__INCLUDED_

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

/////////////////////////////////////////////////////////////////////////////
// CEasySizeDemoDlg dialog

class CEasySizeDemoDlg : public CDialog
{
DECLARE_EASYSIZE
// Construction
public:
	CEasySizeDemoDlg(CWnd* pParent = NULL);	// standard constructor

// Dialog Data
	//{{AFX_DATA(CEasySizeDemoDlg)
	enum { IDD = IDD_EASYSIZEDEMO_DIALOG };
		// NOTE: the ClassWizard will add data members here
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CEasySizeDemoDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	//{{AFX_MSG(CEasySizeDemoDlg)
	virtual BOOL OnInitDialog();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg void OnSize(UINT nType, int cx, int cy);
	afx_msg void OnSizing(UINT fwSide, LPRECT pRect);
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_EASYSIZEDEMODLG_H__8E227342_30AC_44D9_B83A_52321DCD07CE__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.


Written By
Engineer Nokia
Denmark Denmark
My programming experience started a long time ago in
QBasic (on a 25MHz 486).
I'm now mainly using Java, C++, C, MFC, Perl and PHP, but have used quite a number of other languages as well for various projects.

Comments and Discussions