Solved

Calling function in MFC ActiveX from C code

Posted on 2001-06-08
6
249 Views
Last Modified: 2012-08-14
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".

0
Comment
Question by:ianfmurray
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 5

Expert Comment

by:proskig
ID: 6167456
Put a static (extern "C") wrapper around your CX254Ctrl::NcbCompletion.
0
 

Author Comment

by:ianfmurray
ID: 6167565
Sorry but i need more information.
0
 
LVL 5

Expert Comment

by:proskig
ID: 6167696
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

yourObject.NcbCompletion(...);
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Accepted Solution

by:
tdubroff earned 300 total points
ID: 6168923
The main problem is you are trying to call C++ member functions from C code.  The following link provides some insight into this:

http://www.develop.com/hp/slip/ctocpp.pdf

Hope it helps.
0
 

Author Comment

by:ianfmurray
ID: 6182065
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()
{
     FireNcbComplete();

     //CX254Ctrl::NcbCom();
}

In the X254Ctrl.h file I have

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

0
 

Author Comment

by:ianfmurray
ID: 6248783
No more answers since 06/08/2001 so i had better accept the answer
0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question