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);
	}



Comments

  • PropertyPages and the Tab

    Posted by AliRafiee on 01/14/2009 11:13am

    What about the Tab control and the PropertyPages?

    Reply
  • weird property sheet

    Posted by Legacy on 04/20/2000 12:00am

    Originally posted by: vincenzo

    i have a problem , i am writing a sdi application with a dialogbar , in this dialog i embedded a property sheet , but it remains horizontal fixed , i have tried anything , but no way it remains always fixed at 300 pixel , why ?
    if anyone can help me i would REALLY gratefull to him

    Reply
  • Resizing the property sheet dynamically (like resizing a window) at run time -works great!

    Posted by Legacy on 02/16/1999 12:00am

    Originally posted by: Syed Hameed

    Resizing the property sheet dynamically is similar to resizing a window.
    
    I am able to do that dynamically using the following code.

    // Resize the property-sheet
    m_pPropSheet->SetWindowPos(NULL,
    0,
    0,
    cx - 20,
    cy - 80,
    SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);

    For my case, I have placed the above code in the OnSize of the parent window (CDialog type)which works cool.

    Reply
  • Property Sheet Resizable By User

    Posted by Legacy on 02/11/1999 12:00am

    Originally posted by: Ernesto Perales

    if you want a resizable property sheet:
    
    

    BOOL
    CMySheet::OnInitDialog()
    {
    CPropertySheet::OnInitDialog();

    // your code goes here

    // Add size to system menu
    CMenu* pSysMenu = GetSystemMenu(FALSE);
    if (pSysMenu != NULL)
    {
    pSysMenu->InsertMenu(
    -1,MF_BYPOSITION|MF_STRING,SC_SIZE,"&Size");
    }
    // Add resizable frame
    ::SetWindowLong(m_hWnd,GWL_STYLE,
    GetStyle()|WS_THICKFRAME);
    return TRUE;
    }

    void
    CMySheet::OnSize(UINT nType, int cx, int cy)
    {
    CPropertySheet::OnSize(nType, cx, cy);
    CRect r;
    GetClientRect(r);
    if(GetTabControl())
    GetTabControl()->SetWindowPos(NULL,
    0,0,r.Width()-30,r.Height()-30,
    SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE);
    }

    you will have to deal with the property pages, the buttons, but this should get you started

    Reply
  • how to resize a property sheet dynamically just like resizing a application window?

    Posted by Legacy on 01/15/1999 12:00am

    Originally posted by: Ye Hai Bei

    can you upload the code for derived class and demo project that meet my need. i think it is better for my digest.
    thank you.

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

Top White Papers and Webcasts

  • Live Event Date: August 13, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT If you are developing applications, you'll want to join us to learn how applications are changing as a result of gesture recognition. This technology will change how you and your users interact - not simply with your devices, but with the world around you. Your devices will be able to see and hear what your users are doing. Are your applications ready for this? Join us to learn about Intel® RealSense™ Technology, including never been …

  • Savvy enterprises are discovering that the cloud holds the power to transform IT processes and support business objectives. IT departments can use the cloud to redefine the continuum of development and operations—a process that is becoming known as DevOps. Download the Executive Brief DevOps: Why IT Operations Managers Should Care About the Cloud—prepared by Frost & Sullivan and sponsored by IBM—to learn how IBM SmartCloud Application services provide a robust platform that streamlines …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds