Hosting whole Form (not a UserControl) as MFC MDI dialog

G

Guest

CWinFormsDialog in .net 2.0 lets you host a .Net UserControl as a dialog in a
managed C++ MDI application.

I.e. in the sample:
-----------------------------------------------

#include <afxwinforms.h>
#using <WinFormUserControl1.dll>
using namespace WinFormUserControl1;

// CWinFormModeless dialog
class CWinFormModeless : public CWinFormsDialog<WinFormUserControl1Control>
{ ...}
-----------------------------------------------

Its basically a template class that lets you host any of your UserControl.

My question is, Is there any way of using a Form rather than a user control?
Is there any general way in .Net of getting from a Form to a user control?
I basically want to contain an entire form in a user control so that I can
easily add future .Net forms back into my legacy C++ MDI App.

You can show the forms without any of this bother, but when you show them
modeless, they aren't properly contained within the main app window and
dissapear behind it.
 
G

Guest

Heres an update:
I've been experimenting with the new .Net 2.0 CWinFormsDialog as a way of
also including new C# Forms in our legacy Managed C++ MDI application.
Currently (in VS2003) you can show modal .Net forms without any problems,
but if you show a modeless Form it disappears behind the main frame.
CWinFormsDialog is supposed to solve these problems and let you host a user
control as if it was a normal CDialog.
In the sample
(http://www.microsoft.com/downloads/...bc-e575-4fe3-baa9-15aa50b0f599&displaylang=en) it has some text in it as follows:

// This should be the line you use to invoke a Modeless
// CWinFormDialog
//m_pWinFormModeless->Create(CWinFormModeless::IDD);
// But because of a sizing bug you need to use a custom
// dialog template that matches the size of the hosted UserControl
m_pWinFormModeless->Create(IDD_EMPTYDIALOG);

Does anyone have any more information on exactly what the problem is and
when it will be solved?
I'm running:
Microsoft Visual Studio 2005 Team Edition Version 8.0.50727.42
(RTM.050727-4200)
Microsoft .NET Framework Version 2.0.50727
Installed Edition: Enterprise
Microsoft Visual C# 2005 77642-113-3000004-41249

I believe that I may be coming across the sizing problem.
Are there any Microsoft people reading this forum?

Their work around of having an empty dialog resource the same size as the
user control you wish to host is no good for us.
We are basically having a dummy user control that just hosts the form you
pass in to it.
If I could get this working, this would be a nice way of plugging in new
..Net stuff into our legacy applications.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top