Article ID: 237771 - Last Review: September 1, 2005 - Revision: 3.0 BUG: "0x80070057 (E_INVALIDARG - The parameter is incorrect)" error message when you use an ATL to catch an event when an enum is used as a parameter of the eventThis article was previously published under Q237771 SYMPTOMS
An ATL event sink defined with SINK_ENTRY or SINK_ENTRY_EX will fail to catch an event when an enum is used as one of the parameters for the event. The failure code returned by IDispatch::Invoke is "0x80070057 (E_INVALIDARG - The parameter is incorrect)." The event will succeed in another container, such as Visual Basic.
CAUSE
IDispEventImpl's GetFuncInfoFromID method checks the type of the event parameters and, on encountering type VT_USERDEFINED, calls GetUserDefinedType. This method currently checks only for TKIND_ALIAS ("typedef struct" data types) and not TKIND_ENUM.
RESOLUTION
There are several ways to work around this problem. One method is to use the SINK_ENTRY_INFO macro and define an _ATL_FUNC_INFO structure to provide type information for the event method. Use a VT_I4 type for the enum parameter.
For more information about SINK_ENTRY_INFO, click the following article number to view the article in the Microsoft Knowledge Base:
194179
(http://support.microsoft.com/kb/194179/
)
AtlEvnt.exe sample shows how to create ATL sinks by using the ATL IDispEventImpl and IDispEventSimpleImpl classes
If you are using IDispEventImpl<> for the sink, you can override the virtual function GetFuncInfoFromID. A simple override is as follows. STATUSMicrosoft has confirmed that this is a bug in the Microsoft products that are listed in the "Applies to" section.
This problem was corrected in Microsoft Visual C++ .NET.
REFERENCES
For more information, click the following article numbers to view the articles in the Microsoft Knowledge Base:
194179
(http://support.microsoft.com/kb/194179/
)
AtlEvnt.exe sample shows how to creates ATL sinks by using the ATL IDispEventImpl and IDispEventSimpleImpl classes
181277
(http://support.microsoft.com/kb/181277/
)
The AtlSink.exe sample demonstrates how to implement a dispinterface sink by using the Active Template Library (ATL) in Visual C++
See also the ATL Articles in the Visual C++ documentation, specifically "ATL Collections and Enumerators" and "Event Handling in ATL."
| Article Translations
|
Back to the top
