Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to create a simple SDI application
Message
From
24/08/2000 09:57:32
 
 
General information
Forum:
Visual C++
Category:
Microsoft Foundation Classes
Miscellaneous
Thread ID:
00408371
Message ID:
00408718
Views:
10
Thanks a lot Neil for your help, it does work like a charm. I stayed away from the CPropertySheet class because I thought that it came automatically with the "OK", "Cancel" and "Apply" buttons. By reading further in the docs, I see that was not the case.

I'm still confused about the document/view thing, so I did not use it in my first project. I see that it added some new functionality to my form by resizing automatically the dialog inside the frame as the frame is resized and by adding toolbars as needed. Neet.

I still wonder however why my original control did not react to mouse clicks. Any ideas on that issue?

Again, thanks a lot.
>Try the following code, it uses the CFormView as the basis for the document/view architecture.
>
>1. Create a new MFC application and base the view on the CFormView view.
>
>2. When presented with your dialog template in the resource editor put a placeholder control (making sure it is big enough to encompass the pageframe)give it an ID of IDC_PLACEHOLDER, the picture control is probably the best.
>
>3. Create a new class based on CPropertySheet and call it something like CNewPropertySheet. Leave only one constructor and pass in the parent window as a parameter.
>
>CNewPropertySheet(CWnd* pParentWnd = NULL);
>
>4. In the appwizard derived form view class, add a pointer to the new property sheet class (CNewPropertySheet) for later use.
>
>CNewPropertySheet* m_pNewPropSheet;
>
>5. You have add a virtual function handler (if it isn't already there) for WM_INITIALUPDATE in your CFormView derived class.
>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:
>
>CPage1 m_page1;
>CPage2 m_page2;
>.
>.
>.
>
>7. We can now add the page's objects to the property sheet using the AddPage() member function, you must put the code inside the CNewPropertySheet's constructor.
>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.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform