CWinFormsDialog Class

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at CWinFormsDialog Class.

A wrapper for an MFC dialog class that hosts a Windows Forms user control.

template <typename TManagedControl>  
class CWinFormsDialog :   
    public CDialog  

Parameters

TManagedControl
The .NET Framework user control to be displayed in the MFC application.

Public Constructors

NameDescription
CWinFormsDialog::CWinFormsDialogConstructs a CWinFormsDialog object.

Public Methods

NameDescription
CWinFormsDialog::GetControlRetrieves a reference to the Windows Forms user control.
CWinFormsDialog::GetControlHandleRetrieves a window handle to the Windows Forms user control.
CWinFormsDialog::OnInitDialogInitializes the MFC dialog box by creating and hosting a Windows Forms user control on it.

Public Operators

Name
CWinFormsDialog::operator ->Replaces CWinFormsDialog::GetControl in expressions.
CWinFormsDialog::operator TManagedControl^Casts a type as a reference to a Windows Forms user control.

CWinFormsDialog is a wrapper for an MFC dialog class ( CDialog) that hosts a Windows Forms ( UserControl) user control. This allows the display of .NET Framework controls on a modal or modeless MFC dialog box.

For more information on using Windows Forms, see Using a Windows Form User Control in MFC and Hosting a Windows Form User Control as an MFC Dialog Box.

Header: afxwinforms.h

Constructs a CWinFormsDialog object.

CWinFormsDialog(UINT nIDTemplate = IDD);

Parameters

nIDTemplate
Contains the ID of a dialog box template resource. Use the dialog editor to create the dialog template and store it in the application's resource script file. For more information on dialog templates, see CDialog Class.

Retrieves a reference to the Windows Forms user control.

inline TManagedControl^ GetControl() const;  

Return Value

Returns a reference to the UserControl control in the MFC dialog box.

Retrieves a window handle to the Windows Forms user control.

inline HWND GetControlHandle() const throw();

Return Value

Returns a window handle to the Windows Forms user control.

Initializes the MFC dialog box by creating and hosting a Windows Forms user control on it.

virtual BOOL OnInitDialog();

Return Value

A boolean value that specifies whether the application has set the input focus to one of the controls in the dialog box. If OnInitDialog returns nonzero, Windows sets the input focus to the first control in the dialog box. This method can return 0 only if the application has explicitly set the input focus to one of the controls in the dialog box.

Remarks

When the MFC dialog box is created (using the Create, CreateIndirect, or DoModal method inherited from CDialog), a WM_INITDIALOG message is sent and this method is called. It creates an instance of a UserControl control on the dialog box and adjusts the size of the dialog box to accommodate for the size of the user control. Then it hosts the new control in the MFC dialog box.

Override this member function if you need to perform special processing when the dialog box is initialized. For more information on using this method, see CDialog::OnInitDialog.

Replaces CWinFormsDialog::GetControl in expressions.

inline TManagedControl^  operator->() const throw();

Remarks

This operator provides a convenient syntax that replaces GetControl in expressions.

For information on using Windows Forms, see Using a Windows Form User Control in MFC.

Casts a type as a reference to a Windows Forms user control.

inline operator TManagedControl^() const throw();

Remarks

This operator casts a type as a reference to a UserControl control. It is used to pass a CWinFormsDialog<``TManagedControl``> dialog box to functions that accept a pointer to a Windows Forms user control object.

System.Windows.Forms.UserControl
CWnd Class
CWinFormsView Class
CDialog Class

Show: