如何在doc中获得view的指针

解决方案 »

  1.   

    在doc里定义一个CXXXView *pView的指针,然后在CXXXView里调用:
    this->GetDocument()->pView=this;
    就行了
      

  2.   

    GetParentFrame()
    GetActiveView()or(getnexview)
      

  3.   

    可以利用公共变量。xxxApp中 CWnd* m_pViewWnd;
    在VIEW的初始化函数中;
    theApp.m_pViewWnd=this;
    在Doc中你就可以使用theApp.m_pViewWnd了。
    还用一种是直接得到的,如果查到了资料我可以再发给你。
      

  4.   

    这样做
    class CMyDocument:public CDocument
    {
    ......
    public:
       CMyView* m_view;
    };在CMyView中改写OnCreate(...)函数
    BOOL CMyView::OnCreate(...)
    {
    .....
    GetDocument()->m_view = this;
    }