>CWnd* pWndPlaceHolder = GetDlgItem(IDC_PLACEHOLDER); >m_pNewPropSheet = new CNewPropertySheet(pWndPlaceHolder); > >if (!m_pNewPropSheet->Create(pWndPlaceHolder, WS_CHILD | WS_VISIBLE, 0)) >{ > delete m_pNewPropSheet; > m_pNewPropSheet = NULL; > return; >} > >// Resize the property sheet so that it fits in the placeholder control. > >CRect rectPlaceholder; >pWndPlaceHolder->GetWindowRect(rectPlaceholder); >m_pNewPropSheet->SetWindowPos(NULL, 0, 0, > rectPlaceholder.Width(), > rectPlaceholder.Height(), > SWP_NOZORDER | SWP_NOACTIVATE);>6. Create your page classes and derive them from CPropertyPage using the ClassWizard. You will handle the page control's specific messages here, make sure you associate a different IDD_???? to every class. Place member variables to these newly created classes inside the CNewPropertySheet class, for example:
>CNewPropSheet::CNewPropSheet(CWnd* pParentWnd):CPropertySheet(AFX_IDS_APP_TITLE, pParentWnd) >{ > AddPage(&m_page1); > AddPage(&m_page2); >}>8. Avoid memory leaks! In the derived CFormView (I have called mine CDerivedView yours could be anything.) make sure you delete the pointer to the CNewPropertySheet object we allocated on the heap, probably the best place to put this is the destructor.
>CDerivedView::~CDerivedView() >{ > delete m_pNewPropSheet; >}>When you run this sample the pages will have no captions. To add/change the page captions override the CNewPropertySheet::OnInitDialog() virtual function and add the following code.
>CString Caption = _T("Page 1"); >TC_ITEM tcItem; >tcItem.mask = TCIF_TEXT; >tcItem.cchTextMax = _MAX_PATH >tcItem.pszText = (LPTSTR)((LPCTSTR)Caption); > >// The first parameter is the page number which is zero indexed. > >GetTabControl()->SetItem(0, &tcItem);>I have tested this with Visual C++ 6 with SP4, if you want the project then I can email it to you.