none
Redirect from VC++ MFC to C# winform and reverse RRS feed

  • Question

  • Hello,

    I am Manoj,

    I want to redirect from VC++ MFC form to C# form on a button click.

    And reverse on another click.

    Thank you.

    Regards,

    Manoj Shenoy

    Friday, January 11, 2013 7:54 AM

Answers

  • Hello,
     
    Dear Viorel_ , Thanks for your Most helpful and valuable reply.
     
    I want to close the MFC and then redirect to C# winform.
    It might be better to just hide the MFC window:
     
    ShowWindow(SW_HIDE);
    MyClassLibrary::MyForm1 ^ f = gcnew MyClassLibrary::MyForm1;
    f->ShowDialog();
    ShowWindow(SW_SHOW);
     

    David Wilkinson | Visual C++ MVP
    Tuesday, January 15, 2013 4:03 PM

All replies

  • This can be done if you consider this approach:

    • The MFC application is compiled with ‘Common Language Runtime Support (/clr)’ option.
    • The C# form is included into a Class Library or Windows Form Control Library project.
    • The MFC application includes the C# library into the list of referenced assemblies.
    • The MFC and C# applications are compiled for the same platform: either x86 or x64.

    The handler for button click in MFC will look like this:

    MyClassLibrary::MyForm1 ^ f = gcnew MyClassLibrary::MyForm1;

    f->ShowDialog();

    Friday, January 11, 2013 12:18 PM
  • Hello,

    Dear Viorel_ , Thanks for your Most helpful and valuable reply.

    I want to close the MFC and then redirect to C# winform.

    Kindly help me.

    Regards,

    Manoj Shenoy

    Tuesday, January 15, 2013 9:44 AM
  • Hello,
     
    Dear Viorel_ , Thanks for your Most helpful and valuable reply.
     
    I want to close the MFC and then redirect to C# winform.
    It might be better to just hide the MFC window:
     
    ShowWindow(SW_HIDE);
    MyClassLibrary::MyForm1 ^ f = gcnew MyClassLibrary::MyForm1;
    f->ShowDialog();
    ShowWindow(SW_SHOW);
     

    David Wilkinson | Visual C++ MVP
    Tuesday, January 15, 2013 4:03 PM