Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
TRY
Expand Minimize

MAKE_DELEGATE

Attaches an event handler to a managed control.

MAKE_DELEGATE( 
   DELEGATE,
   MEMBER
);

DELEGATE

The type of the managed event handler delegate, such as EventHandler.

MEMBER

The name of the event handler method to be attached to the control.

This macro creates a managed event handler delegate of type DELEGATE and of the name MEMBER. The managed event handler delegate allows a native class to handle managed events.

The following code example shows how to call MAKE_DELEGATE to attach an OnClick event handler to an MFC control MyControl. For a broader explanation of how this macro works in an MFC application, see How to: Sink Windows Forms Events from Native C++ Classes.

// CMyView derives from CWinFormsView. 
void CMyView::OnInitialUpdate()
{
   CWinFormsView::OnInitialUpdate();

   GetControl()->Click += MAKE_DELEGATE(System::EventHandler, OnClick);
}

Header: msclr\event.h

Community Additions

ADD
Show:
© 2015 Microsoft