Calling function in MFC ActiveX from C code

I am new to C++ so forgive me if this is a simple question.

I have a MFC ActiveX made by the Control Wizard, I have included some C code into the project.

I want to call a function in the MFC class from my C code, but the function name is CX254Ctrl::NcbCompletion which C code will not recognise.

I am able to call function in the C code from C++ by using extern "C".

Who is Participating?
tdubroffConnect With a Mentor Commented:
The main problem is you are trying to call C++ member functions from C code.  The following link provides some insight into this:

Hope it helps.
Put a static (extern "C") wrapper around your CX254Ctrl::NcbCompletion.
ianfmurrayAuthor Commented:
Sorry but i need more information.
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

If NcbCompletion is a static function:

extern "C"
foo NcbCompletion(...)
 return CX254Ctrl::NcbCompletion(...);

If not then, inside global NcbCompletion you have to determine object, and call

ianfmurrayAuthor Commented:
I think the comment from tdudroff is pointing in the right direction, but since I am a novice the artical  is a bit to complex for me.

In the X254Ctrl.cpp file I have

void CX254Ctrl::NcbCompletion()


In the X254Ctrl.h file I have

     void NcbIfm();
     void NcbCompletion();
     enum {
     dispidTrace = 1L,
     dispidRemoteNua = 2L,
     dispidNcbReturn = 3L,
     dispidNcbCommand = 4L,
     dispidNcbCommandReturn = 5L,
     dispidClearCall = 6L,
     dispidEntry = 7L,
     dispidMakeCall = 8L,
     dispidProcessNcbCompletion = 9L,
     eventidNcbComplete = 1L,
and am trying to call CX254Ctrl::NcbCompletion() from some C code in the same workspace.

ianfmurrayAuthor Commented:
No more answers since 06/08/2001 so i had better accept the answer
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.