Solved

Calling function in MFC ActiveX from C code

Posted on 2001-06-08
6
241 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

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…
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…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

864 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

19 Experts available now in Live!

Get 1:1 Help Now