I've an app written C & C++. Now, I need to provide a GUI for this app. MFC is the best option for me. But I'm not familiar with MFC.
So can I use .NET to build GUI for this? If so, How? Please be clear.
If I can use .NET I guess I can use WPF too right?
You can use WPF with C++/CLI. It is a . NET API, however, so it requires the . NET Framework.
NET Core 3.1 and Visual Studio 2019, C++/CLI projects can target . NET Core. This support makes it possible to port Windows desktop applications with C++/CLI interop layers to .
You can technically write a GUI in C++/CLI, but I would highly discourage it. C++/CLI is good for writing .NET wrappers around native C++ and exposing it to other .NET languages, but not much else.
In your case, if you're really set on using WinForms/WPF, then I would suggest using C++/CLI to create a wrapper around your C++ code and then building the actual GUI in C#.
Otherwise, a C++ library like Qt or wxWidgets would also suffice for doing a "native" C++ GUI.
Here's a quick introduction to C++/CLI. This is a quick-start guide for getting started with C++/CLI. Once you build a C++/CLI DLL, you can just add it as a reference to your C# project and It Just Works(tm).
Organize the C++ app as a "server", exporting functions which can be called by a GUI "client". Build this C++ code as a DLL, exporting said functions. Create your GUI app as a .NET EXE and let it call said functions in your DLL using Platform Invoke (P/Invoke).
This book also deserves particular mention since it covers advanced topics and using WPF with C++/CLI: C++/CLI in Action (Manning)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With