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: September 10, 2014 Modern mobile applications connect systems-of-engagement (mobile apps) with systems-of-record (traditional IT) to deliver new and innovative business value. But the lifecycle for development of mobile apps is also new and different. Emerging trends in mobile development call for faster delivery of incremental features, coupled with feedback from the users of the app "in the wild." This loop of continuous delivery and continuous feedback is how the best mobile …

  • A modern mobile IT strategy is no longer an option, it is an absolute business necessity. Today's most productive employees are not tied to a desk, an office, or a location. They are mobile. And your company's IT strategy has to be ready to support them with easy, reliable, 24/7 access to the business information they need, from anywhere in the world, across a broad range of communication devices. Here's how some of the nation's most progressive corporations are meeting the many needs of their mobile workers …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds