Click here to Skip to main content
15,915,163 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Problem in Images display on dialog. Pin
_AnsHUMAN_ 18-Mar-09 20:21
_AnsHUMAN_ 18-Mar-09 20:21 
GeneralRe: Problem in Images display on dialog. Pin
hemlat18-Mar-09 21:07
hemlat18-Mar-09 21:07 
GeneralRe: Problem in Images display on dialog. Pin
_AnsHUMAN_ 19-Mar-09 1:23
_AnsHUMAN_ 19-Mar-09 1:23 
GeneralRe: Problem in Images display on dialog. Pin
hemlat19-Mar-09 21:06
hemlat19-Mar-09 21:06 
Questionhow to convert legacy C++ library with nested class and callback to managed code [modified] Pin
Frank_Q18-Mar-09 16:57
Frank_Q18-Mar-09 16:57 
AnswerRe: how to convert legacy C++ library with nested class and callback to managed code Pin
Frank_Q19-Mar-09 16:03
Frank_Q19-Mar-09 16:03 
GeneralRe: how to convert legacy C++ library with nested class and callback to managed code Pin
David Knechtges20-Mar-09 10:07
David Knechtges20-Mar-09 10:07 
GeneralRe: how to convert legacy C++ library with nested class and callback to managed code Pin
Frank_Q21-Mar-09 5:03
Frank_Q21-Mar-09 5:03 
Thanks for the kind reply, David.

Yes, now I learned how to wrap the class functions in a managed c++ library. But I am stuck with the callback function. Previously in our unmanaged C++ applications, in order to use the callback function in the legacy dll, we can just create a new class inheriting the NestedClass1 and implement the virtual function in the new class.

Below is the header file in the legacy dll.
///////////////////////////////
//Legacy dll header file
class MainClass
{
public:
class NestedClass1
{
public:
// This is the entry for call back function
virtual bool OnNestedClass1() = 0;
};
Bool SetCallback(NestedClass1* callback);
}
//End of legacy dll header file
//////////////////////////////
//Below codes shows how to use the call back function
/////////////////////////////////////////////////////
class NestedClass1Child:public NestedClass1
{
MainClass m_mainClass;
void Initialize()
{
m_mainClass.SetCallback(this);
}
virtual bool OnNestedClass1()
{
//Here I insert my code to get the data
int result = RetrieveData();
return true;
}
int RetrieveData()
{
return m_mainClass.GetData();
}
};
///////////////////////////////////////////////////////
As you can see from the above example in unmanaged C++, I just need to implement a child class of the NestedClass1 and then implement the virtual function "OnNestedClass1()".

But the issue now is: the managed class cannot inherit unmanaged class. I am wondering if the delegate is suitable for this case.

I would much appreciate if you could highlight more.

Thank you

Frank

David Knechtges wrote:
Try wrapping it in a managed C++ library. Basically, call the MFC DLL from within the managed C++ library, and then call the managed C++ library from your code. This is the easiest way to do it.

You will need delegates for the callbacks in the managed part. Search for it. There are examples of doing this all over the place.

Questionproblem accessing member functions from LRESULT CALLBACK Function() { } Pin
abiemann18-Mar-09 15:17
abiemann18-Mar-09 15:17 
AnswerRe: problem accessing member functions from LRESULT CALLBACK Function() { } Pin
«_Superman_»18-Mar-09 16:48
professional«_Superman_»18-Mar-09 16:48 
GeneralRe: problem accessing member functions from LRESULT CALLBACK Function() { } Pin
abiemann19-Mar-09 8:18
abiemann19-Mar-09 8:18 
Questiondesign a Kohonen SOM of 15 neurons in a 3X5 rectangular grid Pin
w118sxa18-Mar-09 11:30
w118sxa18-Mar-09 11:30 
AnswerRe: design a Kohonen SOM of 15 neurons in a 3X5 rectangular grid Pin
Maximilien18-Mar-09 12:40
Maximilien18-Mar-09 12:40 
Questionpersistent pointer/memory allocation Pin
Ylno18-Mar-09 10:04
Ylno18-Mar-09 10:04 
AnswerRe: persistent pointer/memory allocation Pin
Joe Woodbury18-Mar-09 10:12
professionalJoe Woodbury18-Mar-09 10:12 
AnswerRe: persistent pointer/memory allocation Pin
Luc Pattyn18-Mar-09 13:19
sitebuilderLuc Pattyn18-Mar-09 13:19 
AnswerRe: persistent pointer/memory allocation Pin
«_Superman_»18-Mar-09 16:53
professional«_Superman_»18-Mar-09 16:53 
AnswerRe: persistent pointer/memory allocation Pin
Eytukan18-Mar-09 19:41
Eytukan18-Mar-09 19:41 
AnswerRe: persistent pointer/memory allocation Pin
abiemann19-Mar-09 8:34
abiemann19-Mar-09 8:34 
QuestionConverting win32 console app. to service ? Pin
mmayur18-Mar-09 10:01
mmayur18-Mar-09 10:01 
AnswerRe: Converting win32 console app. to service ? Pin
Jerry.Wang18-Mar-09 13:52
Jerry.Wang18-Mar-09 13:52 
QuestionSome help on interpreting this makefile for linux... Pin
leslie wu18-Mar-09 7:07
leslie wu18-Mar-09 7:07 
AnswerRe: Some help on interpreting this makefile for linux... Pin
Stuart Dootson18-Mar-09 8:14
professionalStuart Dootson18-Mar-09 8:14 
AnswerRe: Some help on interpreting this makefile for linux... Pin
bolivar12318-Mar-09 8:18
bolivar12318-Mar-09 8:18 
AnswerRe: Some help on interpreting this makefile for linux... Pin
CPallini18-Mar-09 8:35
mveCPallini18-Mar-09 8:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.