Click here to Skip to main content
15,886,045 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hello,

since days I try to fire events from VB and catch them with C++ - unfortunately w/o any success. To my excuse: I am not a VB developer and do not know all the mechanisms used here.

For your better understanding here is my current situation and what I achieved so far:

I want to use a licensed .NET Dll in my MFC/C++ application but cannot use the /clr option for compiling. So I need a wrapper between the managed .NET world and the unmanaged C++.

My first attempt was with C++/Cli. In the end I had a lib that was in principle able to call the .NET Dll but i received every time a License Exception since I could not pass the .NET Dll license key via the lib.

After that the support team of the .NET Dll forwarded a link to an VB Wrapper that is able to communicate with the .NET Dll and works as a COM Object. So I compiled this VB Wrapper and imported the generated dll/tlb in my C++ application. Now I am able to call functions of the .NET Dll via the VB Wrapper.

But since I need to react on events from the .NET Dll as well I tried to catch events withing the VB Wrapper and/or forward them to my C++ application. I have no idea how to catch/fire events in this scenario. I read already a lot of "how to"s but none of them helped me out. There were talked about Connection Points and Callbacks but I cannot imagine how to set this up - neither in VB nor on C++.

I hope some of you guys have a quite simple example that shows how to fire an event within a VB COM Object and how to catch it in a C++ client.
Posted
Updated 22-May-14 19:49pm
v2

1 solution

You should forward your callback function and some parameters up to the C++ App and do messaging via PostThreadMessage

It is best because it is non-blocking by packing the message in the message queue.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900