I am using MFC and C++...

I have a dialog of type CDialog containing several objects including a CPropertySheet called m_dlgPropSheet (which does not have it's own class beyond CPropertySheet). This property sheet contains three identical pages (with different data) of type CPatchSummaryPage which inherits from CPropertyPage.

I am trying to make the dialog resizable. I have a textbox on each page which appears to be resizing fine and maintaining that size, but the size of the page itself is somewhat off and reverts to it's original size whenever you switch tabs.

The following is my code in the dialog:
(IDC_PROPSHEET is the placeholder for the property sheet in the mfc design editor.)

void CAboutDlg::OnSize(UINT nType, int cx, int cy)
{
	if ( m_initialized && nType == SIZE_RESTORED) // When is resized by hand
	{
		CRect rcSheet;
		CRect rcDialog;
		this->GetDlgItem( IDC_PROPSHEET )->ShowWindow( SW_HIDE );
		this->GetDlgItem( IDC_PROPSHEET )->GetWindowRect( &rcSheet );
		this->GetWindowRect( &rcDialog );

		CPoint point;
		point = rcDialog.BottomRight();
		point.x -= 30;
		point.y -= 30;
		
		rcSheet.SetRect(rcSheet.TopLeft(), point);
		ScreenToClient( &rcSheet );

		this->GetDlgItem( IDC_PROPSHEET )->MoveWindow( &rcSheet );
		this->GetDlgItem( IDC_PROPSHEET )->ShowWindow( SW_SHOW );

		m_dlgPropSheet.MoveWindow( &rcSheet );
		m_consolePage.ResizePage( rcSheet );
		m_databasePage.ResizePage( rcSheet );
		m_coreServicesPage.ResizePage( rcSheet );
	}
        CDialog::OnSize(nType, cx, cy);
}

The following is my code inside CPatchSummaryPage:

void CPatchSummaryPage::ResizePage(CRect rcSheet)
{
	SetWindowPos(NULL, 0, 0, rcSheet.Width()-14, rcSheet.Height(), SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
	CRect rcDetails;
	m_detailsText.GetWindowRect( &rcDetails );
	m_detailsText.SetWindowPos(NULL, 0, 0, rcSheet.Width()-14, rcDetails.Height(), SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
}

Thanks in advance!

Here is a quite good explanation for sheets/pages:
http://support.microsoft.com/kb/300606

Thanks for the link. I looked at that code, but I can't seem to get it to compile. It can't find AFX_OLDPROPSHEETHEADER or GetPropSheetHeader() even after including AFXDLGS.H which is where the MFC documentation says that they are defined. Any ideas?

Which version of Visual Studio are you using?

Which version of Visual Studio are you using?

Visual C++ .NET 2003 version 7.1.6030

Try this one as a replacement for the DoModal() introduced in the msdn article (which is for VS 6.0).
I'm not sure whether this one actually compiles with your VS version (I don't have that version at hand now here). A key point here is that your class should have the m_psh member variable.

INT_PTR CMyPropertySheet::DoModal()
{
    m_psh.dwFlags |= PSH_USECALLBACK;
    m_psh.pfnCallback = XmnPropSheetCallback;
    return CPropertySheet::DoModal();
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.