代码之家  ›  专栏  ›  技术社区  ›  Amit G.

cView as选项卡在cmfctabctrl上,不绘制无效区域(拖动时)

  •  1
  • Amit G.  · 技术社区  · 7 年前
    pDocTemplate=new-cmultidocTemplate(idr_MyType,
    运行时类(cmychildframe)
    
    rectDummy.setRectEmpty();
    
    {
    }
    
    
    pwnd1->创建(nullptrnullptr、Lbs聒nointegralheight_ws_child_ws_visible、crect(00300300)、this1、pcontext);
    
    cView测试2*pWnd2=(cView测试2*)运行时类(cView测试2)->createObject();
    pwnd2->设置字体(&afxglobaldata.fontRegular);
    
    添加选项卡(pwnd2,l“tab 2”);
    
    m_kndtabs.setactivetab(1);/(这需要移到1&back to 0)
    
    M_wndtabs调整大小以覆盖整个客户区,位置为:

    cView::onSize(类型,cx,cy); m wndtabs.setwindowpos(nullptr,-1,-1,cx,cy,swp nomove swp noactivate swp nozorder);
    
    
    

    以下内容:

    pDocTemplate = new CMultiDocTemplate(   IDR_MYTYPE,
                                            RUNTIME_CLASS(CMyDoc),
                                            RUNTIME_CLASS(CMyChildFrame),
                                            RUNTIME_CLASS(CMyView));
    

    CMFCTabCtrl(m_wndTabsCViewTest1CViewTest2类(从MFC派生CViewMyView::Create功能:

        CRect rectDummy;
        rectDummy.SetRectEmpty();
    
        // Create tabs window:
        if (!m_wndTabs.Create(CMFCTabCtrl::STYLE_3D_ONENOTE, rectDummy, this, 1))
        {
            TRACE0("Failed to create output tab window\n");
            return -1;      // fail to create
        }
    
        // Create output panes ('300' value is dummy client-rect is updated on CViewTest1/2::OnSize):
    
        CViewTest1 *pWnd1 = (CViewTest1*)RUNTIME_CLASS(CViewTest1)->CreateObject();
        pWnd1->Create(nullptr, nullptr, LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE, CRect(0, 0, 300, 300), this, 1, pContext);
        pWnd1->SetFont(&afxGlobalData.fontRegular);
    
        CViewTest2 *pWnd2 = (CViewTest2*)RUNTIME_CLASS(CViewTest2)->CreateObject();
        pWnd2->Create(nullptr, nullptr, LBS_NOINTEGRALHEIGHT | WS_CHILD | WS_VISIBLE, CRect(0, 0, 300, 300), this, 2, pContext);
        pWnd2->SetFont(&afxGlobalData.fontRegular);
    
        m_wndTabs.AddTab(pWnd1, L"Tab 1");
        m_wndTabs.AddTab(pWnd2, L"Tab 2");
    
        // Redraw tab 0 ("Tab 1"): <--- Here already smells an issue.
        m_wndTabs.SetActiveTab(1); // (This need to move to 1 & back to 0)
        m_wndTabs.SetActiveTab(0);
    

    parentcView测试1查看测试2视图类

    void CMyView::OnSize(UINT nType, int cx, int cy)
    {
        CView::OnSize(nType, cx, cy);
    
        if (m_wndTabs) // Tab control should cover the whole client area:
            m_wndTabs.SetWindowPos(nullptr, -1, -1, cx, cy, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER);
    
    }
    

    现在,当我将一个子帧拖动到另一个子帧上并向后拖动时:控件选项卡的行为如预期的那样,但cView Test1对象(在活动选项卡上)不获取OnDraw()。看起来是这样的:

    enter image description here

    1 回复  |  直到 7 年前
        1
  •  2
  •   xMRi    7 年前

    cView测试1和2是cView类。