Resizable Dialog Box

CResizingDialog is a CDialog derived class that allows the dialog controls to be reordered and resized with the Dialog Box.


To use CResizingDialog :

  1. Replace the base class of your dialog box to CResizingDialog (instead of CDialog)
  2. Change the dialog template to allow resizing border.
  3. From the dialog constructor call SetConrolInfo() to set the behavior of each of your dialog controls on resize.
SetConrolInfo() determines how each control behaves when the user resize the dialog box.
The "Windows default" is ANCHORE_TOP | ANCHORE_LEFT) e.g.

For a right aligned OK button you'll probably call:
SetControlInfo(IDOK, ANCHORE_RIGHT)
For a text control that needs to resize with the dialog you may do:
SetControlInfo(IDD_MYEDITOR, RESIZE_BOTH)



/////////////////////////////////////////////////////////////////////////////
// CSampleDlg dialog

CSampleDlg::CSampleDlg(CWnd* pParent /*=NULL*/)
	: CResizingDialog(CSampleDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSampleDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	CDWordArray c_info;
	SetControlInfo(IDC_LEFT_RESIZE,		RESIZE_HOR | RESIZE_VER);
	SetControlInfo(IDC_BOTTOM_ANCHORE,	ANCHORE_BOTTOM | RESIZE_HOR);
	SetControlInfo(IDOK,			ANCHORE_RIGHT);
	SetControlInfo(IDCANCEL,		ANCHORE_RIGHT);
	SetControlInfo(IDC_RIGHT_VER_RESIZE,	ANCHORE_RIGHT | RESIZE_VER);
	SetControlInfo(IDC_SLIDER1,		ANCHORE_RIGHT | RESIZE_VER);
	
}

void CSampleDlg::DoDataExchange(CDataExchange* pDX)
{
	CResizingDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSampleDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CSampleDlg, CResizingDialog)
	//{{AFX_MSG_MAP(CSampleDlg)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSampleDlg message handlers

void CSampleDlg::OnOK() 
{
	CResizingDialog::OnOK();
}


Download demo project (with Source) - 22 KB

Download class only source - 4 KB

Date Last Updated: January 25, 1999



Comments

  • There are no comments yet. Be the first to comment!

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • IBM Worklight is a mobile application development platform that lets you extend your business to mobile devices. It is designed to provide an open, comprehensive platform to build, run and manage HTML5, hybrid and native mobile apps.

  • In support of their business continuity and disaster recovery plans, many midsized companies endeavor to avoid putting all their eggs in one basket. Understanding the critical role of last-mile connectivity and always available Internet access for their enterprises, savvy firms utilize redundant connections from multiple service providers. Despite the good intentions, their Internet connectivity risk may still be in a single basket. That is because internet service providers (ISPs) and competitive local …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds