FIX: ActiveX Control Events Are Not Fired in ATL Dialog (190530)
The information in this article applies to:
- The Microsoft Active Template Library (ATL) 3.0, when used with:
- Microsoft Visual C++, 32-bit Enterprise Edition 6.0
- Microsoft Visual C++, 32-bit Professional Edition 6.0
- Microsoft Visual C++, 32-bit Learning Edition 6.0
This article was previously published under Q190530 SYMPTOMS
When you insert an ActiveX control on an ATL dialog box, and add event
handlers for it, the event handler is not called.
CAUSE
This problem occurs because the sink objects have not been hooked up to the
corresponding ActiveX control [IConnectionPoint::Advise() has not been
called for each control].
RESOLUTION
For an ATL dialog box, IConnectionPoint::Advise() can be called for each
control on the dialog box, with associated event handlers, by calling
AtlAdviseSinkMap(). Add a message handler for WM_INITDIALOG in the dialog
box and call AtlAdviseSinkMap(). For example:
LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam,
BOOL& bHandled)
{
// Calls IConnectionPoint::Advise() for each control on the dialog
// box with sink map entry.
AtlAdviseSinkMap(this, TRUE);
return 1; // Let the system set the focus.
}
Also, make sure IConnectionPoint::Unadvise() is called for all controls for
which IConnectionPoint::Advise() was called. This is done by calling
AtlAdviseSinkMap() with the value FALSE for last parameter:
LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam,
BOOL& bHandled)
{
// Calls IConnectionPoint::Unadvise() for each control on the dialog
// box with sink map entry.
AtlAdviseSinkMap(this, FALSE);
return 0;
}
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed
at the beginning of this article.
This problem was corrected in Microsoft Visual C++ .NET.
Modification Type: | Major | Last Reviewed: | 12/10/2003 |
---|
Keywords: | kbBug kbConnPts kbCtrl kbDlg kbfix kbNoUpdate KB190530 |
---|
|