WedgeSoft

I have read several question/answers, many MSDN Doc, and made a number of trial and error attempts; but no luck yet -- so thought I would ask.

My win forms app is pure C++/CLI (with just a tad C#). But a need to use an unmanaged DLL as a gateway into my application has been forced onto me. I have been in managed code now for to many years and as I have avoided mixed code, I have forgotten much of my earlier MFC work.

Please, someone hold my hand and give me some step by step, how to create an unmanaged dialog (as a DLL) which I will open upon the load of my CLR Form, that will allow my application to be run or not.




Re: Visual C++ General HowTo: CDialog from C++/CLI Win Froms app

WedgeSoft

I do not have an answer yet. But I did find one interesting example worthy of sharing.

Hosting of MFC MDI applications from within WinForms and WPF

By Alexey Shalnov, On CodeProject.

( 070911 PS -- I was able to create an MFC dialog from my CLR Forms main using the above example. An excellent solution for someone that needs to load some old MFC code under the newer CLR application. But... alas, even though I had success, in the end a third party application (which I must pass through) did not accept the solution. )






Re: Visual C++ General HowTo: CDialog from C++/CLI Win Froms app

Ramkrishna Pawar

You just need to create a Win32 DLL which creates the Dialog box, following might help,

CodeGuru: Countdown Dialog DLL






Re: Visual C++ General HowTo: CDialog from C++/CLI Win Froms app

WedgeSoft

Thank you; but...

I managed to create a dll that I called from my C++/CLR Win Forms app using the information from the CodeProject example (above). But, it did not pass through third party software as I had hoped it would.

Now I have another idea that will pass the third party needs. I create a Win32 app as a dll that does not try and open a window. I'll do the necessary processing in the Win32 dll, and marshal the data back to my CLR Forms for display. So far so good. I know the dll passes the third party test, and I feel good that I can do the required processing and marshal the data back. I think I understand how to export the functions I will be using within the dll.

BUT... I can not figure out how to connect with the dll. I can't simply include it. I can't use #using. I can't use LoadLibrary().

I create the Win32 dll as part of my solution. The dll exists in my solutions debug folder. I can add it as a reference to my CLR Forms solution.

How do I make a call from within my CLR Forms to one of the exported functions within the win32 dll






Re: Visual C++ General HowTo: CDialog from C++/CLI Win Froms app

WedgeSoft

Copied from another thread: "How to access Win32 dll from CLR Forms App "

The answer (below) does not allow one to open a dialog; but does provide acess to with a win32 dll.

============

Here is simple answer for return of int.

-------------------------------------------------

In the CLR consol app .h, use namespace System::Runtime::InteropServices and use the attribute DllImport

[ DllImport( "MyDll" ) ]

int SomeCall(void);

And in the consol app.cpp just call SomeCall as normal.

-------------------------------------------------

In the Win32 app, export the function:

extern "C" __declspec(dllexport)

int SomeCall(void) {}