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 20, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT When you look at natural user interfaces as a developer, it isn't just fun and games. There are some very serious, real-world usage models of how things can help make the world a better place – things like Intel® RealSense™ technology. Check out this upcoming eSeminar and join the panel of experts, both from inside and outside of Intel, as they discuss how natural user interfaces will likely be getting adopted in a wide variety …

  • Corporate e-Learning technology has a long and diverse pedigree. As far back as the 1980s, companies were adopting computer-based training to supplement traditional classroom activities. More recently, rich web-based applications have added streaming audio and video, real-time collaboration and other new tools to the e-Learning mix. At the same time, the growing availability of informal learning tools--a category that includes everything from web searches to social media posts--are having a major impact on …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds