다음을 통해 공유


CWinFormsControl 클래스

Windows Forms 컨트롤을 호스팅하기 위한 기본 기능을 제공합니다.

구문

template<class TManagedControl>
class CWinFormsControl : public CWnd

매개 변수

TManagedControl
MFC 애플리케이션에 표시할 .NET Framework Windows Forms 컨트롤입니다.

멤버

공용 생성자

속성 설명
CWinFormsControl::CWinFormsControl MFC Windows Forms 컨트롤 래퍼 개체를 생성합니다.

공용 메서드

이름 설명
CWinFormsControl::CreateManagedControl MFC 컨테이너에 Windows Forms 컨트롤을 만듭니다.
CWinFormsControl::GetControl Windows Forms 컨트롤에 대한 포인터를 검색합니다.
CWinFormsControl::GetControlHandle Windows Forms 컨트롤에 대한 핸들을 검색합니다.

Public 연산자

이름 설명
CWinFormsControl::operator -> 식에서 CWinFormsControl::GetControl 을 대체합니다.
CWinFormsControl::operator TManagedControl^ 형식을 Windows Forms 컨트롤에 대한 포인터로 캐스팅합니다.

설명

이 클래스는 CWinFormsControl Windows Forms 컨트롤을 호스팅하기 위한 기본 기능을 제공합니다.

Windows Forms 사용에 대한 자세한 내용은 MFC에서 Windows Form 사용자 컨트롤 사용을 참조하세요.

MFC 코드는 창 핸들(일반적으로 저장 m_hWnd됨)을 캐시해서는 안 됩니다. 일부 Windows Forms 컨트롤 속성을 사용 하 여 기본 Win32 Window 를 제거 하 고 다시 만들어야 합니다CreateWindow.DestroyWindow MFC Windows Forms 구현은 멤버를 Destroy 업데이트 m_hWnd 하는 컨트롤의 이벤트와 Create 해당 이벤트를 처리합니다.

참고 항목

MFC Windows Forms 통합은 MFC(AFXDLL이 정의됨)와 동적으로 연결되는 프로젝트에서만 작동합니다.

요구 사항

헤더: afxwinforms.h

CWinFormsControl::CreateManagedControl

MFC 컨테이너에 Windows Forms 컨트롤을 만듭니다.

inline BOOL CreateManagedControl(
    System::Type^ pType,
    DWORD dwStyle,
    const RECT& rect,
    CWnd* pParentWnd,
    int nID)
inline BOOL CreateManagedControl(
    DWORD dwStyle,
    const RECT& rect,
    CWnd* pParentWnd,
    int nID);

inline BOOL CreateManagedControl(
    DWORD dwStyle,
    int nPlaceHolderID,
    CWnd* pParentWnd);

inline BOOL CreateManagedControl(
    typename TManagedControl^ pControl,
    DWORD dwStyle,
    const RECT& rect,
    CWnd* pParentWnd,
    int nID);

매개 변수

pType
만들 컨트롤의 데이터 형식입니다. 형식 데이터 형식이어야 합니다.

dwStyle
컨트롤에 적용할 창 스타일입니다. 창 스타일 조합을 지정합니다. 현재 WS_TABSTOP, WS_VISIBLE, WS_DISABLED 및 WS_GROUP 스타일만 지원됩니다.

rect
컨트롤의 왼쪽 위와 오른쪽 아래 모퉁이의 좌표를 정의하는 RECT 구조체입니다(첫 번째 오버로드만 해당).

nPlaceHolderID
리소스 편집기에서 배치된 정적 자리 표시자 컨트롤의 핸들입니다. 새로 만든 Windows Forms 컨트롤은 위치, z 순서 및 스타일(두 번째 오버로드에만 해당)을 가정하여 정적 컨트롤을 대체합니다.

pParentWnd
부모 창에 대한 포인터입니다.

nID
새로 만든 컨트롤에 할당할 리소스 ID 번호입니다.

pControl
CWinFormsControl 개체와 연결할 Windows Forms 컨트롤의 인스턴스입니다(네 번째 오버로드에만 해당).

Return Value

성공하면 0이 아닌 값을 반환합니다. 실패하면 0을 반환합니다.

설명

이 메서드는 MFC 컨테이너에서 .NET Framework Windows Forms 컨트롤을 인스턴스화합니다.

메서드의 첫 번째 오버로드는 MFC가 이 형식의 새 개체를 인스턴스화할 수 있도록 .NET Framework 데이터 형식 pType 을 허용합니다. pType형식 데이터 형식이어야 합니다.

메서드의 두 번째 오버로드는 클래스의 템플릿 매개 변수를 TManagedControl 기반으로 Windows Forms 컨트롤을 CWinFormsControl 만듭니다. 컨트롤의 크기와 위치는 메서드에 RECT 전달된 구조체를 기반으로 합니다. dwStyle스타일에 중요합니다.

메서드의 세 번째 오버로드는 정적 컨트롤을 대체하는 Windows Forms 컨트롤을 만들어 삭제하고 위치, z 순서 및 스타일을 가정합니다. 정적 컨트롤은 Windows Forms 컨트롤의 자리 표시자로만 사용됩니다. 컨트롤을 만들 때 이 오버로드는 dwStyle의 스타일을 정적 컨트롤의 리소스 스타일과 결합합니다.

메서드의 네 번째 오버로드를 사용하면 MFC가 래핑할 이미 인스턴스화된 Windows Forms 컨트롤 pControl 을 전달할 수 있습니다. 클래스의 템플릿 매개 변수 CWinFormsControlTManagedControl 동일한 형식이어야 합니다.

Windows Form 컨트롤 사용에 대한 샘플은 MFC에서 Windows Form 사용자 컨트롤 사용을 참조하세요.

CWinFormsControl::CWinFormsControl

MFC Windows Forms 컨트롤 래퍼 개체를 생성합니다.

CWinFormsControl();

설명

CWinFormsControl::CreateManagedControl을 호출하면 Windows Forms 컨트롤이 인스턴스화됩니다.

CWinFormsControl::GetControl

Windows Forms 컨트롤에 대한 포인터를 검색합니다.

inline TManagedControl^ GetControl() const;

Return Value

Windows Forms 컨트롤에 대한 포인터를 반환합니다.

예시

CWinFormsControl::CreateManagedControl을 참조하세요.

CWinFormsControl::GetControlHandle

Windows Forms 컨트롤에 대한 핸들을 검색합니다.

inline HWND GetControlHandle() const;

Return Value

Windows Forms 컨트롤에 대한 핸들을 반환합니다.

설명

GetControlHandle 는 .NET Framework 컨트롤 속성에 저장된 창 핸들을 반환하는 도우미 메서드입니다. CWnd::Attach를 호출하는 동안 창 핸들 값이 CWnd::m_hWnd 복사됩니다.

CWinFormsControl::operator ->

식에서 CWinFormsControl::GetControl 을 대체합니다.

inline TManagedControl^  operator->() const;

설명

이 연산자는 식에서 대체하는 GetControl 편리한 구문을 제공합니다.

Windows Forms에 대한 자세한 내용은 MFC에서 Windows Form 사용자 컨트롤 사용을 참조하세요.

CWinFormsControl::operator TManagedControl^

형식을 Windows Forms 컨트롤에 대한 포인터로 캐스팅합니다.

inline operator TManagedControl^() const;

설명

이 연산자는 CWinFormsControl<TManagedControl> Windows Forms 컨트롤에 대한 포인터를 허용하는 함수로 전달됩니다.

참고 항목

CWinFormsDialog 클래스
CWinFormsView 클래스