0

After a bunch of reading this afternoon, and not getting any tangible results. Is it possible to host a windows forms dialog inside of a MFC application that is still being developed using VC6.

The issue arises is that we have a large application that has never been upgraded with the new Visual Studios because VC6 always worked. Now we need to add some of the C# functionality in it. I am unable to do the /clr option as our project consists entirely of unmanaged C++. I did a search for "CWinFormsControl" within all our libraries/headers and didn't come up with anything. I am unsure what to try next.

Also, forgive any ignorance as I am doing research and new to this depth of programming.

I have checked the following articles:

2 Answers 2

2

CWinFormsControl requires MFC 8.0.

You can make your managed assembly a COM server (e.g. ActiveX) and use it in MFC application like any other COM server.

Sign up to request clarification or add additional context in comments.

2 Comments

Following the directions I went ahead and got a DLL built of my C# dialog. How do I call/initialize it in C++ now? Forgive the ignorance.
CoCreateInstance, call your form's ShowDialog method via early (#import +tlbexp) or late bing (IDispatch).
1

I don't have VC6 laying around to try this out, but I think it should be mostly possible; at least for a simple modal ShowDialog() scenario.

You'll create a new assembly/DLL using C++/CLI, compiled with the /clr flag. This will expose an unmanaged API to your existing MFC code, using the usual __declspec(dllexport). The implementation will call into your C# code which lives it yet another assembly.

1 Comment

What is the best way to do this? I'm very new to this. Any pointers in the right direction would be helpful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.