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

  • Today's agile organizations pose operations teams with a tremendous challenge: to deploy new releases to production immediately after development and testing is completed. To ensure that applications are deployed successfully, an automatic and transparent process is required. We refer to this process as Zero Touch Deployment™. This white paper reviews two approaches to Zero Touch Deployment--a script-based solution and a release automation platform. The article discusses how each can solve the key …

  • Learn How A Global Entertainment Company Saw a 448% ROI Every business today uses software to manage systems, deliver products, and empower employees to do their jobs. But software inevitably breaks, and when it does, businesses lose money -- in the form of dissatisfied customers, missed SLAs or lost productivity. PagerDuty, an operations performance platform, solves this problem by helping operations engineers and developers more effectively manage and resolve incidents across a company's global operations. …

Most Popular Programming Stories

More for Developers

RSS Feeds