Solved

Calling function in MFC ActiveX from C code

Posted on 2001-06-08
6
243 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
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
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 clear a vector as well as how to detect empty vectors in C++.
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.

770 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