Hello Everyone,
I have created an MFC ole control in c++ and I have an issue when I paste the control onto a blank Word Page (Word 2013) it is bigger than the page size.
If I reduce the drawing before I copy it onto the clipboard, it works fine.
I have seen an event named :
BOOL CMeasGraphCtrl::OnSetExtent(LPSIZEL lpSizeL)
but I do not get access to the client site rectangle size during the paste procedure.
I wonder if somebody has already worked in this area to reduce the control size if it is outside the client container size.
How to reach the 'container size' to adjust it to fit the container size properly ?
Does somebody have an idea how to auto adjust the control size ?
Thank you very much in advance.
Best regards,
MiQi
What I have tried:
I have done the following experimentation:
BOOL CMeasGraphCtrl::OnSetExtent(LPSIZEL lpSizeL)
{
BOOL bRet = FALSE;
if (m_bChangingExtent)
return FALSE;
SIZEL sizeHiMetric;
_AfxXformSizeInHimetricToPixels(NULL, lpSizeL, &sizeHiMetric);
SIZEL sizeExtentPixels;
SIZEL sizeExtentHimetric;
sizeExtentPixels.cx = m_cxExtent;
sizeExtentPixels.cy = m_cyExtent;
_AfxXformSizeInPixelsToHimetric(NULL, &sizeExtentPixels, &sizeExtentHimetric);
int cx, cy;
SIZEL controlSizePixels;
SIZEL controlSizHiMetric;
GetControlSize(&cx, &cy);
controlSizePixels.cx = cx;
controlSizePixels.cy = cy;
_AfxXformSizeInPixelsToHimetric(NULL, &controlSizePixels, &controlSizHiMetric);
if (m_pInPlaceSite != nullptr)
{
RECT rcClientRect;
GetClientRect(&rcClientRect);
SIZEL controlSize;
SIZEL controlSizeHiMetric;
controlSize.cx = cx;
controlSize.cy = cy;
AtlPixelToHiMetric(&controlSize, &controlSizeHiMetric);
RECT rcRectInContainer;
GetRectInContainer(&rcRectInContainer);
ClipCaretRect(&rcRectInContainer);
}
bRet = COleControl::OnSetExtent(lpSizeL);
return bRet;
}