// Code in the header file:
virtual BOOL OnSetObjectRects(LPCRECT lpRectPos, LPCRECT lpRectClip);
// Code in the implementation file:
#include <afxpriv2.h>
#include <..\src\afximpl.h>
#include <..\src\ctlimpl.h>
void MyGetClippingCoordinates(LPCRECT pPosRect, LPCRECT pClipRect,
LPRECT pIntersectRect, LPPOINT pOffsetPoint)
{
int clipLeft = 0;
int clipTop = 0;
if ((pClipRect == NULL) || IsRectEmpty(pClipRect))
{
CopyRect(pIntersectRect, pPosRect);
}
else
{
IntersectRect(pIntersectRect, pPosRect, pClipRect);
clipLeft = pClipRect->left;
clipTop = pClipRect->top;
}
pOffsetPoint->x = min(0, pPosRect->left - clipLeft);
pOffsetPoint->y = min(0, pPosRect->top - clipTop);
}
BOOL CTmpCtrl::OnSetObjectRects(LPCRECT lprcPosRect, LPCRECT lprcClipRect)
{
// return COleControl::OnSetObjectRects(lprcPosRect, lprcClipRect);
ASSERT(lprcPosRect != NULL);
// Remember the position rectangle.
m_rcPos = *lprcPosRect;
// Calculate complete rectangle, include the tracker if it is present.
CRect rectPos = m_rcPos;
if (m_bUIActive && m_pRectTracker != NULL)
{
// Save new clipping rectangle (for DestroyTracker).
if (lprcClipRect != NULL)
m_pRectTracker->m_rectClip = *lprcClipRect;
// Adjust tracker rectangle to new dimensions.
CRect rectTmp = rectPos;
rectTmp.OffsetRect(-rectTmp.left, -rectTmp.top);
m_pRectTracker->m_rect = rectTmp;
// Adjust the "true" rectangle to include handles/hatching.
UINT nHandleSize = m_pRectTracker->m_nHandleSize - 1;
rectPos.InflateRect(nHandleSize, nHandleSize);
}
// Now clip the rectangle as appropriate.
CRect rectClip;
MyGetClippingCoordinates(rectPos, lprcClipRect, rectClip, &m_ptOffset);
// Move the outer window first, and then move the inner window.
if (!m_bInPlaceSiteWndless)
{
CWnd* pWndOuter = GetOuterWindow();
//BEGIN CHANGE.
if (pWndOuter != NULL)
{
static CRect oldClipRect(0, 0, 0, 0);
if (oldClipRect != rectClip)
::MoveWindow(pWndOuter->m_hWnd,
rectClip.left, rectClip.top,
rectClip.Width(), rectClip.Height(),
TRUE);
oldClipRect = rectClip;
}
//END CHANGE.
if (pWndOuter != this)
MoveWindow(m_ptOffset.x, m_ptOffset.y,
rectPos.Width(), rectPos.Height());
}
return TRUE;
}