Article ID: 168326
Article Last Modified on 11/21/2006
BOOL CTestCtrl::OnSetExtent(LPSIZEL lpSizeL)
{
// This function limits the height of a control to be at
// least 20 pixels.
// Use the desktop window to get a DC so we can use
// CDC::HIMETRICtoDP and CDC::DPtoHIMETRIC
CWnd *pWnd = CWnd::FromHandle(::GetDesktopWindow());
CClientDC dc(pWnd);
CSize sz(lpSizeL->cx,lpSizeL->cy);
dc.HIMETRICtoDP(&sz); //Convert the size to pixels
if (sz.cy < 20)
return false;
return COleControl::OnSetExtent(lpSizeL);
}
Note that the code is identical up to and including the line that says
"if (sz.cy is greater than 20)". The new code also lacks the "TRACE" lines.
Additional query words: ocx
Keywords: kbhowto kbctrl KB168326