是否就是说你的主VIEW的WM_PAINT多响应了一次?
用breakpoint看看

解决方案 »

  1.   

    我的一个 View 上嵌了一个Excel,每次刚运行或者从其他窗口后出来的时候,Excel 的表格闪烁了一下,然后被一片白色覆盖,我怀疑是 CSplitterWnd 画了两次,以至于覆盖了 Excel 表格,我不知道用 breakpoint 能否找到问题.
      

  2.   

    如果拉动一下分割条, Excel 就正常地显示了,我用 breakpoint 不知道怎样调试,因为每次显示之前程序总能运行到 OnPaint
      

  3.   

    按你所说不是被画了两次,你的Excel是动态创建的吗??
      

  4.   

    在View的OnInitUpdate中用COleClientItem::CreateNewItem生成的
      

  5.   

    void CMFCBindView::OnDraw(CDC* pDC)
    {
    CMozartDoc* pDoc = GetDocument();
    ASSERT_VALID(pDoc); // DocObjects don't require any drawing
    }void CMFCBindView::OnInitialUpdate()
    {
    CView::OnInitialUpdate(); if(m_pSelection)
    return;      CMFCBindCntrItem* pItem = NULL;
    TRY
    {
    // Create new item connected to this document.
    pItem = new CMFCBindCntrItem(GetDocument());
    ASSERT_VALID(pItem);
    CLSID clsid;
    if(FAILED(::CLSIDFromProgID(OLESTR("Excel.sheet"),&clsid))){
    delete pItem;
    AfxThrowMemoryException();
    }
             // Create the Excel embedded item.
    if(!pItem->CreateNewItem(clsid)){
                   //Any exception will do. We just need to break out of the
                   //TRY statement.
    if(pItem)
    delete pItem;
    AfxMessageBox("创建 COM 失败,可能是内存不足.");
    }
    ASSERT_VALID(pItem); // make sure we deactivate any active items first.
    COleClientItem* pActiveItem = GetDocument()->GetInPlaceActiveItem(this);
    if (pActiveItem != NULL)
    pActiveItem->Deactivate(); // If item created from class list (not from file) then launch
    //  the server to edit the item.
    pItem->Activate(OLEIVERB_SHOW, this);
    ASSERT_VALID(pItem); // As an arbitrary user interface design, this sets the selection
    //  to the last item inserted. // TODO: reimplement selection as appropriate for your application // set selection to last inserted item
    m_pSelection = pItem; }
    CATCH(CException , e)
    {
    if (pItem != NULL)
    {
    ASSERT_VALID(pItem);
    pItem->Delete();
    GetDocument()->RemoveItem(pItem);
    }
    //e->Delete();
    AfxMessageBox("Failed.");
    }
    END_CATCH
    }
    以上是生成 COleClientItem* m_pSelection的过程
    CMFCBindCntrItem inherited from COleClientItem
      

  6.   

    BOOL CGfxSplitterWnd::OnEraseBkgnd(CDC* pDC) 
    {
    //return CSplitterWnd::OnEraseBkgnd(pDC); CRect rectClient;
    GetClientRect(rectClient);
    rectClient.InflateRect(-m_cxBorder, -m_cyBorder);
    rectClient.bottom = rectClient.top + m_upBorder;
    pDC->FillSolidRect(rectClient, GetSysColor(COLOR_3DFACE));
    return true;
    }void CGfxSplitterWnd::OnPaint()
    {
    CSplitterWnd::OnPaint();
    if (bWhiteLine)
    {

    CClientDC dc(this);
    CRect rectClient;
    GetClientRect(rectClient); //the Top Line
    CPen pn(PS_SOLID, 1, GetSysColor(COLOR_3DSHADOW));
    CPen * op = dc.SelectObject(&pn);
    dc.MoveTo(rectClient.left, rectClient.top);
    dc.LineTo(rectClient.right, rectClient.top);
    CPen pn1(PS_SOLID, 1, GetSysColor(COLOR_3DHILIGHT));
    dc.SelectObject(&pn1);
    dc.MoveTo(rectClient.left, rectClient.top+1);
    dc.LineTo(rectClient.right, rectClient.top+1);
    // the  Bottom line 
    //dc.SelectObject(GetStockObject(BLACK_PEN) );
    //dc.MoveTo(rectClient.left, rectClient.bottom-1);
    //dc.LineTo(rectClient.right, rectClient.bottom-1); dc.SelectObject(op);
    }
    }
    void CGfxSplitterWnd::OnDrawSplitter(CDC* pDC, ESplitType nType, const CRect& rectArg)
    {
    //CSplitterWnd::OnDrawSplitter(pDC,nType,rectArg);

    if (pDC == NULL)
    {
    RedrawWindow(rectArg, NULL, RDW_INVALIDATE|RDW_NOCHILDREN);
    return;
    }
    ASSERT_VALID(pDC);
    CRect rect = rectArg;
    switch (nType)
    {
    case splitBorder:
    return;
    case splitBox:
    pDC->Draw3dRect(rect, GetSysColor(COLOR_3DFACE), GetSysColor(COLOR_WINDOWFRAME));
    rect.InflateRect(-CX_BORDER, -CY_BORDER);
    pDC->Draw3dRect(rect, GetSysColor(COLOR_BTNHIGHLIGHT), GetSysColor(COLOR_BTNSHADOW));
    rect.InflateRect(-CX_BORDER, -CY_BORDER);
    break;
    } COLORREF clr = GetSysColor(COLOR_3DFACE);
    pDC->FillSolidRect(rect, clr);
    }
    以上是 CSplitterWnd 的部分重载函数
      

  7.   

    哇,一大团!!
     能把工程发过来吗?(因为在网吧,save money) :p
      

  8.   

    很抱歉,有个 1G 多的SQL Server在后台,如果哪天你有更多空,我剥离开之后发给你,我记住了你的邮箱