Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Calling function in MFC ActiveX from C code

Posted on 2001-06-08
6
Medium Priority
?
252 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
Technology Partners: 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 900 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

660 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