Solved

Calling function in MFC ActiveX from C code

Posted on 2001-06-08
6
237 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
  • 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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
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.

746 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now