我是今天才接触到属性页的,可能问的问题很幼稚,各位大侠不要笑。好像书上很少提到这个控件,也可能是我看书少吧,所以在网上下了一些源码来看。照着一个例子做,它是单文档结构,在视类中定义了一个CPropertySheet类对像,然后在CPorpertySheet类的构造函数中加入由CPropertyPage类派生出来的对话框,编译出来的结果如http://my.poco.cn/images/myphoto/20040818/26314220040818084740.jpg。这个例程是用属性页标签来切换对话框,但是我是想通过属性页标签来切换视图,这些视图可以是普通视图,也可以是自定义的视图或FormView等别的视,不知道应该如何实现,恳请各位大侠赐教!!

解决方案 »

  1.   

    PropertyView:
    http://www.vccode.com/file_show.php?id=677
      

  2.   

    这几个例子更合适
    http://www.codeguru.com/Cpp/W-D/doc_view/tabs/article.php/c3305/
    http://www.codeguru.com/Cpp/W-D/doc_view/tabs/article.php/c3327/其实直接用工具栏或者菜单切换也可以。
      

  3.   

    http://www.codeguru.com/Cpp/W-D/doc_view/
      

  4.   

    http://www.codeguru.com/Cpp/controls/propertysheet/article.php/c571/
    http://www.codeguru.com/Cpp/controls/propertysheet/article.php/c623/
      

  5.   

    你的问题是视图问题呀
    CVSmspApp* app=(CVSmspApp*)AfxGetApp();
        app->str="穆谱表";
    CDocTemplate* pTemplate=((CVSmspApp*)AfxGetApp())->m_temp1;
        POSITION curTemplatePos = AfxGetApp()->GetFirstDocTemplatePosition();
    pTemplate->OpenDocumentFile(NULL,1);class CVSmspApp : public CWinApp
    {
    public:
    CString str;

    CMultiDocTemplate* m_temp1;

    CVSmspApp();// Overrides
    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CVSmspApp)
    public:
    virtual BOOL InitInstance();
    virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo);
    //}}AFX_VIRTUAL// Implementation
    //{{AFX_MSG(CVSmspApp)
    afx_msg void OnAppAbout();
    afx_msg void OnFileOpen();
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
    };
      

  6.   

    http://www.codeproject.com/docview/tabbedmdi.asp楼上,你没有选择具体栏吧,比如基础类
      

  7.   

    不好意思,我是直接从自己的代码中给你粘贴上的
    m_temp1是在
    // VSmsp.cpp : Defines the class behaviors for the application.
    //#include "stdafx.h"
    #include "VSmsp.h"
    #include "MainFrm.h"
    #include "ChildFrm.h"
    #include "VSmspDoc.h"
    #include "VSmspView.h"
    #include "CurveFrame.h"
    #include "CurveDoc.h"
    #include "CurveView.h"
    #ifdef _DEBUG
    #define new DEBUG_NEW
    #undef THIS_FILE
    static char THIS_FILE[] = __FILE__;
    #endif/////////////////////////////////////////////////////////////////////////////
    // CVSmspAppBEGIN_MESSAGE_MAP(CVSmspApp, CWinApp)
    //{{AFX_MSG_MAP(CVSmspApp)
    ON_COMMAND(ID_APP_ABOUT, OnAppAbout)
    ON_COMMAND(ID_FILE_OPEN, OnFileOpen)
    //}}AFX_MSG_MAP
    // Standard file based document commands
    ON_COMMAND(ID_FILE_NEW, CWinApp::OnFileNew)
    ON_COMMAND(ID_FILE_OPEN, CWinApp::OnFileOpen)
    // Standard print setup command
    ON_COMMAND(ID_FILE_PRINT_SETUP, CWinApp::OnFilePrintSetup)
    END_MESSAGE_MAP()/////////////////////////////////////////////////////////////////////////////
    // CVSmspApp constructionCVSmspApp::CVSmspApp()
    {
    // TODO: add construction code here,
    // Place all significant initialization in InitInstance
    }/////////////////////////////////////////////////////////////////////////////
    // The one and only CVSmspApp objectCVSmspApp theApp;/////////////////////////////////////////////////////////////////////////////
    // CVSmspApp initializationBOOL CVSmspApp::InitInstance()
    {
    AfxEnableControlContainer(); // Standard initialization
    // If you are not using these features and wish to reduce the size
    //  of your final executable, you should remove from the following
    //  the specific initialization routines you do not need.#ifdef _AFXDLL
    Enable3dControls(); // Call this when using MFC in a shared DLL
    #else
    Enable3dControlsStatic(); // Call this when linking to MFC statically
    #endif // Change the registry key under which our settings are stored.
    // TODO: You should modify this string to be something appropriate
    // such as the name of your company or organization.
    SetRegistryKey(_T("Local AppWizard-Generated Applications")); LoadStdProfileSettings();  // Load standard INI file options (including MRU) // Register the application's document templates.  Document templates
    //  serve as the connection between documents, frame windows and views. CMultiDocTemplate* pDocTemplate;


    pDocTemplate = new CMultiDocTemplate(
    IDR_VSMSPTYPE,
    RUNTIME_CLASS(CCurveDoc),
    RUNTIME_CLASS(CCurveFrame), // custom MDI child frame
    RUNTIME_CLASS(CCurveView));
    AddDocTemplate(pDocTemplate);

    pDocTemplate = new CMultiDocTemplate(
    IDR_VSMSPTYPE,
    RUNTIME_CLASS(CVSmspDoc),
    RUNTIME_CLASS(CChildFrame), // custom MDI child frame
    RUNTIME_CLASS(CVSmspView));
    AddDocTemplate(pDocTemplate);
    m_temp1=pDocTemplate;
    // create main MDI Frame window
    CMainFrame* pMainFrame = new CMainFrame;
    if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
    return FALSE;
    m_pMainWnd = pMainFrame;     // Parse command line for standard shell commands, DDE, file open
    CCommandLineInfo cmdInfo;
    ParseCommandLine(cmdInfo); // Dispatch commands specified on the command line
    //if (!ProcessShellCommand(cmdInfo))
    // return FALSE; // The main window has been initialized, so show and update it.
    pMainFrame->ShowWindow(m_nCmdShow);
    pMainFrame->UpdateWindow();
       
    return TRUE;
    }
    /////////////////////////////////////////////////////////////////////////////
    // CAboutDlg dialog used for App Aboutclass CAboutDlg : public CDialog
    {
    public:
    CAboutDlg();// Dialog Data
    //{{AFX_DATA(CAboutDlg)
    enum { IDD = IDD_ABOUTBOX };
    //}}AFX_DATA // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CAboutDlg)
    protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
    //}}AFX_VIRTUAL// Implementation
    protected:
    //{{AFX_MSG(CAboutDlg)
    // No message handlers
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
    };CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
    {
    //{{AFX_DATA_INIT(CAboutDlg)
    //}}AFX_DATA_INIT
    }void CAboutDlg::DoDataExchange(CDataExchange* pDX)
    {
    CDialog::DoDataExchange(pDX);
    //{{AFX_DATA_MAP(CAboutDlg)
    //}}AFX_DATA_MAP
    }BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
    //{{AFX_MSG_MAP(CAboutDlg)
    // No message handlers
    //}}AFX_MSG_MAP
    END_MESSAGE_MAP()// App command to run the dialog
    void CVSmspApp::OnAppAbout()
    {
    CAboutDlg aboutDlg;
    aboutDlg.DoModal();
    }/////////////////////////////////////////////////////////////////////////////
    // CVSmspApp message handlers
    void CVSmspApp::OnFileOpen() 
    {
    //CMainFrame *pFrame=(CMainFrame*)(AfxGetApp()->m_pMainWnd);
    //OnFileOpen();
    //pFrame->SendMessage(ID_FILE_OPEN,BN_CLICKED);
    //ON_CONTROL_RANGE(BN_CLICKED, ID_FILE_OPEN, ID_FILE_OPEN,OnFileOpen)
    }BOOL CVSmspApp::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) 
    {   if(nID==ID_FILE_OPEN)
    return 0;
        return CWinApp::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
    }
    中的指向一文档的指针CVSmspDoc
    RUNTIME_CLASS(CVSmspDoc),
    RUNTIME_CLASS(CChildFrame), // custom MDI child frame
    RUNTIME_CLASS(CVSmspView));
    以后想要打开一个文档用这几句话就可以了CDocTemplate* pTemplate=((CVSmspApp*)AfxGetApp())->m_temp1;
    POSITION curTemplatePos = AfxGetApp()->GetFirstDocTemplatePosition();
    pTemplate->OpenDocumentFile(NULL,1);
    关掉一文档用
    void CMainFrame::CloseActiveFrame(CString title)
    {CWnd *pWnd1;
     CWnd *pWnd=CWnd::FromHandle(m_hWndMDIClient)->GetWindow(GW_CHILD);
     int n=10;
     while(pWnd)
     {
      pWnd1=pWnd->GetWindow(GW_HWNDNEXT);
      pWnd->DestroyWindow();
      if(pWnd1==NULL)return;
      pWnd=pWnd1;
         
     }}
    然后调用这个函数就行了