Microsoft KB Archive/165020

= INFO: Responding to Mouse Events with MFC ActiveX Controls =

Article ID: 165020

Article Last Modified on 11/21/2006

-

APPLIES TO

 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 4.0 Standard Edition

 Microsoft Visual C++ 4.1 Subscription

 Microsoft Visual C++ 4.2 Enterprise Edition

 Microsoft Visual C++ 4.2 Professional Edition</li></ul>

 Microsoft Visual C++ 5.0 Enterprise Edition</li></ul>

 Microsoft Visual C++ 5.0 Professional Edition</li></ul>

 Microsoft Visual C++ 6.0 Enterprise Edition</li></ul>

 Microsoft Visual C++ 6.0 Professional Edition</li></ul>

 Microsoft Visual C++ 6.0 Standard Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q165020

<div class="summary_section">

SUMMARY
MFC-based ActiveX controls capture mouse input by calling SetCapture in response to a mouse-button message. This can cause unexpected problems, but the behavior is by design.

<div class="moreinformation_section">

MORE INFORMATION
If you need to perform an action in response to a mouse button message when implementing an ActiveX control, and that action involves the use of the mouse (for example, displaying a message box or modal dialog box), you need to perform the action after the call to the base class implementation of the handler. Performing such actions prior to calling the base class may result in mouse capture problems.

<div class="references_section">

Sample Code
void CMyButton::OnLButtonDown(UINT nFlags, CPoint point) {      // Handle default first so that the mouse capture is resolved. COleControl::OnLButtonDown(nFlags, point);

// Then, add your own hander code afterwards. MessageBox(_T("No more problem!")); }

Keywords: kbctrl kbinfo KB165020

-

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

© Microsoft Corporation. All rights reserved.