Article ID: 161872 - Last Review: October 24, 2003 - Revision: 2.0

FIX: ActiveX Control Fails to Fire Click Event

This article was previously published under Q161872
Expand all | Collapse all

SYMPTOMS

If you create an ActiveX control that subclasses a button, you may find that the control doesn't fire a "click" event. You can observe this behavior by running the BUTTON sample included with Visual C++ 4.2.

CAUSE

There is a bug in the COleControl::OnLButtonUp() function. CWnd::OnLButtonUp() should be called within the function before calling COleControl::ButtonUp().

RESOLUTION

You can work around the problem by trapping the WM_LBUTTONUP message in your control. Copy the code from the OnLButtonUp() function located in \MSDEV\MFC\SRC\CTLEVENT.CPP and place it into your new handler. Move the call to CWnd::OnLButtonUp() before the call to ButtonUp() so that the new function looks like the following:
   void CYourButtonCtrl::OnLButtonUp(UINT nFlags, CPoint point)
   {
      HWND hWndSave = m_hWnd;
      CWnd::OnLButtonUp(nFlags, point);  // moved the call here

           ButtonUp(LEFT_BUTTON, nFlags, point);
      if (m_hWnd != hWndSave)
         return;

      if (m_bInPlaceActive && !m_bUIActive && m_bPendingUIActivation &&
         (GetFocus() == this || IsChild(GetFocus())))
      {
         m_bPendingUIActivation = FALSE;
         OnActivateInPlace(TRUE, NULL);
      }
   }
				

STATUS

Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug was corrected in Visual C++ version 4.2b.

REFERENCES

For more information about Visual C++ 4.2b, please see the following article in the Microsoft Knowledge Base:
156934  (http://support.microsoft.com/kb/156934/EN-US/ ) PATCH: Visual C++ 4.2b Patch

APPLIES TO
  • Microsoft Visual C++ 4.2 Enterprise Edition
  • Microsoft Visual C++ 4.2 Professional Edition
Keywords: 
kbbug kbfix kbfix KB161872
Retired KB ArticleRetired KB Content Disclaimer
This article was written about products for which Microsoft no longer offers support. Therefore, this article is offered "as is" and will no longer be updated.
 

Article Translations