I wrote a vc++ code to call a method from an ActiveX Cotrol (an OCX file), no compile error, but when I run it , error message is
"Program: ...
Module:
File: i386\chkesp.c
Line: 42
The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.
"
The problem occurs when I call Sum method which is come from the ActiveX control.
Can you help me, thanks.
----vcDraw.cpp-----
#include <iostream>
#include <comdef.h>
#include "vcDrawOCX.h"
using namespace std;
void main()
{
HRESULT hr;
_OCXControl *ItestDraw = NULL;
hr = CoInitialize(0);
if (SUCCEEDED(hr))
{
hr = CoCreateInstance(CLSID_OCXControl,
NULL,
CLSCTX_INPROC_SERVER,
IID__OCXControl,
(void**) &ItestDraw);
if (SUCCEEDED(hr))
{
hr = ItestDraw->Sum();
hr = ItestDraw->Release();
}
else
{
cout<<"CoCreateInstance Failed."<<endl;
}
}
CoUninitialize();
}
----ActiveX control written in
VB------
Option Explicit
Private Sub UserControl_Initialize()
MsgBox "OCXControl initialized OK mmm"
End Sub
Public Sub Sum()
MsgBox "I am from sum"
End Sub