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

  • Protecting business operations means shifting the priorities around availability from disaster recovery to business continuity. Enterprises are shifting their focus from recovery from a disaster to preventing the disaster in the first place. With this change in mindset, disaster recovery is no longer the first line of defense; the organizations with a smarter business continuity practice are less impacted when disasters strike. This SmartSelect will provide insight to help guide your enterprise toward better …

  • Event Date: April 15, 2014 The ability to effectively set sales goals, assign quotas and territories, bring new people on board and quickly make adjustments to the sales force is often crucial to success--and to the field experience! But for sales operations leaders, managing the administrative processes, systems, data and various departments to get it all right can often be difficult, inefficient and manually intensive. Register for this webinar and learn how you can: Align sales goals, quotas and …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds