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

  • On-demand Event Event Date: October 23, 2014 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 webcast to learn why physical appliances are preferable to virtual backup appliances, …

  • IBM Worklight is a mobile application development platform that lets you extend your business to mobile devices. It is designed to provide an open, comprehensive platform to build, run and manage HTML5, hybrid and native mobile apps.

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds