我想在一个文档中定一个工作线程向一个视图用PostMessage发消息但现在不知怎样取得哪个视图的句柄?

解决方案 »

  1.   

    使用CDocument类的GetFirstViewPosition和GetNextView方法可以获得View的类的应用(和该Document相关联的)下面的代码是MSDN里的范例:POSITION pos = GetFirstViewPosition();
    CView* pFirstView = GetNextView( pos );
    // This example uses CDocument::GetFirstViewPosition
    // and GetNextView to repaint each view.
    void CMyDoc::OnRepaintAllViews()
    {
       POSITION pos = GetFirstViewPosition();
       while (pos != NULL)
       {
          CView* pView = GetNextView(pos);
          pView->UpdateWindow();
       }   
    }
    good luck
      

  2.   

    POSITION pos=pDocument->GetFirstViewPosition();
    while(pos!=NULL)
    {
    CYourView* pView = DYNAMIC_DOWNCAST(CYourView,m_pDocument->GetNextView(pos));
    if(pView)
    {
    ...
    }
    }