BUG: ActiveX Control Events Are Not Fired in ATL DialogID: Q190530
|
When you insert an ActiveX control on an ATL dialog box, and add event handlers for it, the event handler is not called.
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].
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;
}
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.
© Microsoft Corporation 1998, All Rights Reserved.
Contributions by Jaganathan Thangavelu, Microsoft Corporation
Additional query words: kbATL300 kbATL300bug kbATL kbVC600 kbVC600bug
Keywords : kbVC600bug kbATL300bug
Version : WINDOWS:3.0
Platform : WINDOWS
Issue type : kbbug
Last Reviewed: July 23, 1999