按照书上语句一字一句的写,能运行就是点击属性菜单后无法弹出对应的属性表单对话框。
点了后还打印显示propSheet()Failed...  

解决方案 »

  1.   

    // PropSheet.cpp : 实现文件
    //#include "stdafx.h"
    #include "Prop.h"
    #include "PropSheet.h"
    // CPropSheetIMPLEMENT_DYNAMIC(CPropSheet, CPropertySheet)CPropSheet::CPropSheet(UINT nIDCaption, CWnd* pParentWnd, UINT iSelectPage)
    :CPropertySheet(nIDCaption, pParentWnd, iSelectPage)
    {

    AddPage((CPropertyPage*)&m_p1);
    AddPage((CPropertyPage*)&m_p2);
    AddPage((CPropertyPage*)&m_p3);
    }
    CPropSheet::CPropSheet(LPCTSTR pszCaption, CWnd* pParentWnd, UINT iSelectPage)
    :CPropertySheet(pszCaption, pParentWnd, iSelectPage)


    AddPage((CPropertyPage*)&m_p1);
    AddPage((CPropertyPage*)&m_p2);
    AddPage((CPropertyPage*)&m_p3);
    }
    CPropSheet::~CPropSheet()
    {
    }
    BEGIN_MESSAGE_MAP(CPropSheet, CPropertySheet)
    END_MESSAGE_MAP()
    #include "PropDoc.h"
    #include "PropView.h"
    #include "PropSheet.h"
    #ifdef _DEBUG
    #define new DEBUG_NEW
    #endif
    // CPropView
    IMPLEMENT_DYNCREATE(CPropView, CView)BEGIN_MESSAGE_MAP(CPropView, CView)
    ON_WM_CONTEXTMENU()
    ON_WM_RBUTTONUP()
    ON_COMMAND(IDM_PROPERTYSHEET, &CPropView::OnPropertysheet)
    END_MESSAGE_MAP()// CPropView 构造/析构CPropView::CPropView()
    {
    // TODO: 在此处添加构造代码}
    CPropView::~CPropView()
    {
    }
    BOOL CPropView::PreCreateWindow(CREATESTRUCT& cs)
    {
    // TODO: 在此处通过修改
    //  CREATESTRUCT cs 来修改窗口类或样式 return CView::PreCreateWindow(cs);
    }
    // CPropView 绘制void CPropView::OnDraw(CDC* /*pDC*/)
    {
    CPropDoc* pDoc = GetDocument();
    ASSERT_VALID(pDoc);
    if (!pDoc)
    return; // TODO: 在此处为本机数据添加绘制代码
    }
    void CPropView::OnRButtonUp(UINT /* nFlags */, CPoint point)
    {
    ClientToScreen(&point);
    OnContextMenu(this, point);
    }void CPropView::OnContextMenu(CWnd* /* pWnd */, CPoint point)
    {
    #ifndef SHARED_HANDLERS
    theApp.GetContextMenuManager()->ShowPopupMenu(IDR_POPUP_EDIT, point.x, point.y, this, TRUE);
    #endif
    }// CPropView 诊断#ifdef _DEBUG
    void CPropView::AssertValid() const
    {
    CView::AssertValid();
    }
    void CPropView::Dump(CDumpContext& dc) const
    {
    CView::Dump(dc);
    }CPropDoc* CPropView::GetDocument() const // 非调试版本是内联的
    {
    ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CPropDoc)));
    return (CPropDoc*)m_pDocument;
    }
    #endif //_DEBUG
    // CPropView 消息处理程序
    void CPropView::OnPropertysheet()
    {
    // TODO: 在此添加命令处理程序代码
    CPropertySheet propSheet("单子");
    propSheet.DoModal();
    }