小弟在看别人的代码发现有这么一个函数,但是不明白什么意思。其中一句是:
if ( DCB_RESET == pDC->GetBoundsRect(&MyRect,DCB_RESET))//MyRect是传进来的参数
pDC->SetBoundsRect(NULL,DCB_ENABLE);通过调试还是不清楚什么意思,在网上查百度词条也不明白什么意思,在整个Microsoft Visual Studio 9.0目录下也没找到GetBoundsRect的实现。请教高人给指点一下GetBoundsRect与SetBoundsRect的用法,具体点,最好能举个例子,另外为什么找不到GetBoundsRect的实现?谢谢了

解决方案 »

  1.   

    CDC::GetBoundsRectUINT GetBoundsRect(LPRECT lpRectBounds,UINT flags);返回值:
    如果成功,则返回外接矩形的当前状态。可以是以下值的组合: DCB_ACCUMULATE 出现外接矩形聚集。  
    DCB_RESET 外接矩形为空。  
    DCB_SET 外接矩形非空。  
    DCB_ENABLE 显示外接矩形。  
    DCB_DISABLE 不显示外接矩形。  参数: lpRectBounds 指向缓冲区的指针。该缓冲区接收当前的外接矩形,矩形用逻辑坐标表示。  
    flags 指定当外接矩形返回后是否被清除,可以为下列值之一: · DCB_RESET 返回后被清除。  
    · DCB_WINDOWMGR 查询Windows而非应用的外接矩形。  
     说明:为指定设备上下文返回当前聚集的外接矩形。请参阅:CDC::SetBoundsRect, ::GetBoundsRect 
      

  2.   

    白度不行??google一下就出来了
    http://msdn.microsoft.com/en-us/library/yah4scb3(VS.80).aspx
    http://msdn.microsoft.com/en-us/library/05h01afz(VS.80).aspx
      

  3.   

    这些我都看了,但还是不明白怎么用。
    因为我调试程序的时候发现传进去的MyRect始终不变,但是GetBoundsRect函数不是把MyRect变成了0就是原封不动。小弟愚昧不理解。请举个例子说明,谢谢。
      

  4.   

    这是源码:
    //CSubWnd是从CWnd派生的
    void CSubWnd::Show(CRect MyRect, LPCTSTR MyTipText)
    {
    CClientDC MyDC(this);
    pDC = CDC::FromHandle(MyDC.m_hDC);
    CString MyTitle(MyTipText);
    MyTitle += _T("  ");
    CFont *pFont = m_pMyWnd->GetFont(); 
    pDC->SelectObject(pFont );
    CRect MyDisplayRect =MyRect;
    if ( DCB_RESET == pDC->GetBoundsRect(&MyRect,DCB_RESET))
    pDC->SetBoundsRect(NULL,DCB_ENABLE);
    pDC->SetTextColor(RGB(255,255,0));
    if( IsWindowVisible() ) 
    {
    MoveWindow(MyDisplayRect.left, MyDisplayRect.top,MyDisplayRect.Width(), MyDisplayRect.Height());
    pDC->FillSolidRect(&MyRect,RGB(0,0,255));
    MyDisplayRect = MyRect;
    MyDisplayRect.left += 2;
    pDC->DrawText(MyTitle,-1,MyDisplayRect, DT_LEFT | DT_SINGLELINE|DT_NOPREFIX | DT_NOCLIP | DT_VCENTER);
    pDC->DrawFocusRect(&MyRect); 
    }
    else
    {
    SetWindowPos( &wndTop, MyDisplayRect.left, MyDisplayRect.top,MyDisplayRect.Width(), MyDisplayRect.Height(),SWP_SHOWWINDOW|SWP_NOACTIVATE );
    pDC->SetBkMode( OPAQUE );
    pDC->FillSolidRect(&MyRect,::GetSysColor(COLOR_HIGHLIGHT));
    pDC->DrawText(MyTitle,-1,MyDisplayRect, DT_LEFT | DT_SINGLELINE | DT_NOPREFIX |DT_NOCLIP | DT_VCENTER);
    pDC->DrawFocusRect(&MyRect);
    }
    }帮解释一下那句到底什么意思?具体点,谢谢大虾
      

  5.   

    Accumulated Bounding Rectangle
    The accumulated bounding rectangle is the smallest rectangle enclosing the portion of a window or client area affected by recent drawing operations. An application can use this rectangle to conveniently determine the extent of changes caused by drawing operations. It is sometimes used in conjunction with LockWindowUpdate to determine which portion of the client area must be redrawn after the update lock is cleared. An application uses the SetBoundsRect function (specifying DCB_ENABLE) to begin accumulating the bounding rectangle. The system subsequently accumulates points for the bounding rectangle as the application uses the specified display device context. The application can retrieve the current bounding rectangle at any time by using the GetBoundsRect function. The application stops the accumulation by calling SetBoundsRect again, specifying the DCB_DISABLE value.