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

  • Live Event Date: October 29, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you interested in building a cognitive application using the power of IBM Watson? Need a platform that provides speed and ease for rapidly deploying this application? Join Chris Madison, Watson Solution Architect, as he walks through the process of building a Watson powered application on IBM Bluemix. Chris will talk about the new Watson Services just released on IBM bluemix, but more importantly he will do a step by step cognitive …

  • Live Event Date: October 23, 2014 @ 12:00 p.m. ET / 9:00 a.m. PT Despite the current "virtualize everything" mentality, there are advantages to utilizing physical hardware for certain tasks. This is especially true for backups. In many cases, it is clearly in an organization's best interest to make use of physical, purpose-built backup appliances rather than relying on virtual backup software (VBA - Virtual Backup Appliances). Join us for this eSeminar to learn why physical appliances are preferable to …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds