Resizing the Property Sheet

The property sheet is not resizable by the user. That is, the user cannot drag an edge of the property sheet dialog to resize it. However, resizing the property sheet programmatically is the same as resizing any other window – get the window dimension by calling GetWindowRect(), modify the dimension and then resize the window by calling the MoveWindow() or the SetWindowPos() function. The code fragment below is from a member function of a CPropertySheet derived class. It increases the width of the property sheet by 100 pixels.

	CRect rectWnd;
	GetWindowRect(rectWnd);
	SetWindowPos(NULL, 0, 0,
		rectWnd.Width() + 100,
		rectWnd.Height(),
		SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);

One of the effects of resizing the property sheet is that the standard buttons get left behind in an aesthetically undesirable position. Its usually a good idea to follow the resize of the property sheet with a move of the standard buttons. Assuming that the Cancel, OK and Apply buttons are visible, code below moves them 100 pixels to the right to match the increase in width of the property sheet.

	int ids[] = { IDOK, IDCANCEL, ID_APPLY_NOW };
	for( int i =0; i < sizeof(ids)/sizeof(ids[0]); i++)
	{
		GetDlgItem(ids[i])->GetWindowRect(rectWnd);
		ScreenToClient(rectWnd);
		rectWnd.right += 100;
		rectWnd.left += 100;
		GetDlgItem(ids[i])->MoveWindow(rectWnd);
	}

More by Author

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Must Read