C# to C++/MFC duplex mode - Concept

Hello,
I have a static MFC C++ application, I cannot change it. (CLI is not possible)
I now need to pass data from a C# DLL in the C++ application and transfer it from the C++ to the C# DLL. What possibilities do I have to implement this successfully.
Can you show an example
SendDataOrderToCPP(string order, double price, int amount)
ResponseDataOrderToCSharp(string order, double price, int amount)
-----
Is there a possibility that the C# DLL sends an event and I can evaluate the value in the C++ app?
Is it possible that the C++ exe sends an event and I can evaluate the value in the C# DLL?
How would I have to create this?
//----
Background
I need to implement a WinForm in C# in which I can make inputs. I have to analyse these inputs in C++.
After the analysis, I have to send new data from C++ to C# to display the calculated values.
Or I need an additional DLL ?
There are many things I do not understand. Can you change the MFC program at all? Or is it impossible to make any changes to the MFC program? Or are there some changes but some you cannot make? It is difficult to know what to suggest because we do not know what the requirements are. Does the MFC program call the DLL currently? I do not understand what in the C++ application means. You say from a C# DLL and you say from the C++ so do you mean both directions? Is data going in both directions now or just one direction or none?
I compile the C++ MFC as a static library and can make few changes in the settings there, hence the idea with the intermediate C++/CLI dll.
No only if inpossible.
Yes
Yes for some function. C# send the inputs of an order.
MFC dialog C++ App
Yes both
Can you make sample, how I can change the data from C# to C++ and back.
Thanks.
You say elsewhere that your C++ application is an MFC dialog application, so presumably when you mention static library, you just mean that its built with MFC statically linked to it?
If it's an MFC dialog application, with no existing interface to access the functionality you need, and you can't re-use or alter its source code, its time to give up.
The community has no idea how your C++ is designed.
Function export is an option.
The official docs cover this subject.
Finally there's Google...
That's bad, I'll try again.
The CPP application must call the C# MainWindow via a command or a function.
The second function is GetOrderArticles().
Is order booked. Send the order to the input mask.
After the CPP app has opened the input dialogue of the C# DLL, the operator enters data such as order, quantity, price.
With the OK button, the data is transmitted to CPP.
Then the CPP application checks the data and sends the order, price and so on to the C#DLL.
The CPP application must be able to control
Application dialogue visible or invisible.
Alternatively, close and open.
Maybe you or the community have tips and suggestions.
I need concrete examples of data communication.
@Markus Freitag
If you could chang the MFC and c# program, as far as I'm concerned you could try to call sendmessage to this aim.
Sign in to comment