Compartir a través de


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.

Syntax

template <typename TManagedControl>  
class CWinFormsDialog :   
    public CDialog  

Parameters

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

Members

Public Constructors

Name Description
CWinFormsDialog::CWinFormsDialog Constructs a CWinFormsDialog object.

Public Methods

Name Description
CWinFormsDialog::GetControl Retrieves a reference to the Windows Forms user control.
CWinFormsDialog::GetControlHandle Retrieves a window handle to the Windows Forms user control.
CWinFormsDialog::OnInitDialog Initializes 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.

Remarks

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.

Requirements

Header: afxwinforms.h

CWinFormsDialog::CWinFormsDialog

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.

CWinFormsDialog::GetControl

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.

CWinFormsDialog::GetControlHandle

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.

CWinFormsDialog::OnInitDialog

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.

CWinFormsDialog::operator ->

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.

CWinFormsDialog::operator TManagedControl^

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.

See Also

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