locked
Open an C# form in C++ MFC RRS feed

  • Question

  •  

    We have an C# form that need to be open in MFC C++ (Unmanaged), how can this be done easily?

    If you have a small example of that it will be appreciated.

    Thanks

    Tuesday, September 12, 2006 2:19 PM

Answers

  • You cannot open and implement a winform's functionality with C++/MFC quite as easily as you might expect, at least not while having the C++/MFC app native.

    What you can do, is to have the MFC app be mixed mode (compiled with /clr), and the residing in an class library. You could easily reference and make calls to the fully managed form, as well as implement callbacks.

    If you for some reason do not want the MFC application to be mixed mode, you can have a mixed mode dll inbetween (serving a native interface to the MFC app, and a managed one to the form). This latter alternative will impose some stress with regard to integration, as you do have a couple of more steps of indirection, possible data conversion and so forth. Callbacks may also be a tricky thing to deal with -- yet quite possible.

    I may be wrong about this, though (as I'm not very familiar with MFC). http://www.microsoft.com/downloads/details.aspx?FamilyID=987021bc-e575-4fe3-baa9-15aa50b0f599&DisplayLang=en leads me to believe that the integration may be done in a simpler manner. Download the examples and have a look.

    Tuesday, September 12, 2006 2:35 PM

All replies

  • You cannot open and implement a winform's functionality with C++/MFC quite as easily as you might expect, at least not while having the C++/MFC app native.

    What you can do, is to have the MFC app be mixed mode (compiled with /clr), and the residing in an class library. You could easily reference and make calls to the fully managed form, as well as implement callbacks.

    If you for some reason do not want the MFC application to be mixed mode, you can have a mixed mode dll inbetween (serving a native interface to the MFC app, and a managed one to the form). This latter alternative will impose some stress with regard to integration, as you do have a couple of more steps of indirection, possible data conversion and so forth. Callbacks may also be a tricky thing to deal with -- yet quite possible.

    I may be wrong about this, though (as I'm not very familiar with MFC). http://www.microsoft.com/downloads/details.aspx?FamilyID=987021bc-e575-4fe3-baa9-15aa50b0f599&DisplayLang=en leads me to believe that the integration may be done in a simpler manner. Download the examples and have a look.

    Tuesday, September 12, 2006 2:35 PM
  • Thanks,

    I've just find the example(just before you reply ;) ) and it's seem that it can work, but I discover that this will not be the better to do it. In facts, I will create a new Windows Control Library that will be in C# and can be used by ours others softwares.

     

    Thanks again!!

    Tuesday, September 12, 2006 2:44 PM