Microsoft KB Archive/182434

= PRB: ActiveX Control's Stock Error Event Uses SCODE Value =

Article ID: 182434

Article Last Modified on 11/21/2006

-

APPLIES TO

 Microsoft Foundation Class Library 4.2, when used with:  Microsoft Visual C++ 4.2 Enterprise Edition

 Microsoft Visual C++ 4.2 Professional Edition

 Microsoft Visual C++ 5.0 Enterprise Edition

 Microsoft Visual C++ 5.0 Professional Edition</li></ul>

 Microsoft Visual C++ 6.0 Enterprise Edition</li></ul>

 Microsoft Visual C++ 6.0 Professional Edition</li></ul>

 Microsoft Visual C++ 6.0 Standard Edition</li></ul> </li></ul>

-

<div class="notice_section">

This article was previously published under Q182434

<div class="symptoms_section">

SYMPTOMS
The event handler generated by ClassWizard does not get called.

<div class="cause_section">

CAUSE
The following is a quotation from the online documentation of COleControl::FireError function: <pre class="fixed_text">  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.

<div class="resolution_section">

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.

<div class="moreinformation_section">

Sample Code
// In the .cpp file of the test container: // CMyTestDlg is a test container (a dialog-based application) // written in Visual C++. BEGIN_EVENTSINK_MAP(CMyTestDlg, CDialog) //AFX_EVENTSINK_MAP END_EVENTSINK_MAP // OnErrorOleCtrl1 is the event handler for the Stock Error event of the // ActiveX control. void CMyTestDlg::OnErrorOleCtrl1(  short       Number,   BSTR FAR*    Description,   long       Scode,          // Change LONG to SCODE!!!   LPCTSTR    Source,   LPCTSTR    HelpFile,   long       HelpContext,   BOOL FAR*    CancelDisplay) {     // TODO: Add your control notification handler code here. ...  } Copyright, Microsoft Corporation 1998, All Rights Reserved. Contributions by Yeong-Kah Tam, Microsoft Corporation

Keywords: kbctrl kbinprocsvr kbprb KB182434

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.