Microsoft KB Archive/270029

= BUG: COleControl::SetControlSize Function Does Not Work =

Article ID: 270029

Article Last Modified on 8/19/2005

-

APPLIES TO


 * Microsoft Windows CE Toolkit for Visual C++ 6.0
 * Microsoft Office Keyboard

-



This article was previously published under Q270029



SYMPTOMS
When you use the COleControl::SetControlSize function from within a Windows CE (WCE) Microsoft Foundation Classes (MFC) ActiveX ControlWizard generated ActiveX control, the ActiveX control does not resize properly.



RESOLUTION
To solve the problem, in addition to calling the COleControl::SetControlSize function, also call the SetWindowPos Win32 API function to resize the parent window of the control as shown in the following code example: BOOL gfTest = FALSE;

void CMYCONTROLCtrl::OnLButtonDown(UINT nFlags, CPoint point) {   if (gfTest) { gfTest = FALSE; ((CWnd*)this)->GetParent->SetWindowPos(NULL, 0, 0, 100, 100, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); SetControlSize(100, 100); }   else { gfTest = TRUE; ((CWnd*)this)->GetParent->SetWindowPos(NULL, 0, 0, 200, 200, SWP_NOZORDER | SWP_NOMOVE | SWP_NOACTIVATE); SetControlSize(200, 200); }

COleControl::OnLButtonDown(nFlags, point); }



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce Behavior
 Create a new ActiveX control by using the eVC WCE MFC ActiveX Control Wizard and accept all the default settings. Use the ClassWizard to add a handler for the WM_LBUTTONDOWN message.  Within the message handler add the following code, which does resize the control when you left-click the control: BOOL gfTest = FALSE;

void CMYCONTROLCtrl::OnLButtonDown(UINT nFlags, CPoint point) {   // TODO: Add your message handler code here and/or call default if (gfTest) { gfTest = FALSE; SetControlSize(100, 100); }   else { gfTest = TRUE; SetControlSize(200, 200); }

COleControl::OnLButtonDown(nFlags, point); }                    Compile, link and deploy the ActiveX control. Host the control within an eVB or eVC application.RESULT: The control does not resize when you left-click the control.</ol>

Additional query words: SetControlSize ActiveX wince

Keywords: kbbug kbcodesnippet kbpending KB270029

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.