PRB: ActiveX Control's Stock Error Event Uses SCODE Value (182434)
The information in this article applies to:
- The Microsoft Foundation Classes (MFC), when used with:
- Microsoft Visual C++, 32-bit Enterprise Edition 4.2
- Microsoft Visual C++, 32-bit Professional Edition 4.2
- Microsoft Visual C++, 32-bit Enterprise Edition 5.0
- Microsoft Visual C++, 32-bit Professional Edition 5.0
- 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 Q182434 SYMPTOMS
The event handler generated by ClassWizard does not get called.
CAUSE
The following is a quotation from the online documentation of
COleControl::FireError() function:
The implementation of an OLE control's Stock Error event uses an SCODE
value. If your control uses this event, and is intended to be used in
Visual Basic 4.0, you will receive errors because the SCODE value is not
supported in Visual Basic.
When you go into the .odl file of the ActiveX control and change the stock
error event from SCODE to LONG as required by Visual Basic, the change
works correctly in Visual Basic.
However, ClassWizard generates an event handler according to the
information it obtains from the .odl file. As a result, the event handler
in the test container written in Visual C++ will have a LONG instead of
SCODE value.
RESOLUTION
The following are two possible solutions:
- Keep two .odl files. One for Visual C++ (has an SCODE parameter type)
and the other for Visual Basic (has a LONG parameter type).
- Manually modify the event handler generated by ClassWizard from SCODE to
LONG, and change VTS_I4 to VTS_SCODE in the ON_EVENT macro of the event
sink map. Refer to the sample code below for these changes.
Modification Type: | Major | Last Reviewed: | 12/2/2003 |
---|
Keywords: | kbCtrl kbInprocSvr kbprb KB182434 |
---|
|