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: 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 29, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT It's well understood how critical version control is for code. However, its importance to DevOps isn't always recognized. The 2014 DevOps Survey of Practice shows that one of the key predictors of DevOps success is putting all production environment artifacts into version control. In this eSeminar, Gene Kim will discuss these survey findings and will share woeful tales of artifact management gone wrong! Gene will also share examples of how …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds