By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,231 Members | 1,707 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,231 IT Pros & Developers. It's quick & easy.

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

P: n/a
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.
May 23 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
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/d...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.

"James" wrote:
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.

May 26 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.