Share via


CreateDelegate(class,class::method,IXRDelegate<ArgType, SenderType>) (Compact 2013)

3/28/2014

This function creates a delegate for an event. The delegate represents the event handler that you specify in the parameters.

Syntax

template <class T, typename ArgType, typename SenderType>
HRESULT CreateDelegate(
  T* pT, 
  HRESULT (T::*pfn)(SenderType*, ArgType*), 
  IXRDelegate<ArgType, SenderType>** ppResult
)

Parameters

  • pT
    [in] Handle to an instance of a custom handler object that implements the event handler.
  • T::*pfn
    [in] Handle to a method in the custom handler object that handles the event associated with the delegate.

    This parameter provides the fully qualified name of the event handler that handles the particular event that you want a delegate for, combined with the name of the event that the delegate handles.

    For example, the following value indicates the creation of a delegate for an OnMouseMove event handler implemented in an object named CustomEventHandler:

    &CustomEventHandler::OnMouseMove
    

Return Value

Returns an HRESULT that indicates success or failure.

Remarks

When you use this helper function, you can first create a custom object that provides custom event handlers. Then, you can pass an instance of that object into pT.

CreateDelegate creates a delegate template class that represents the event handler that you specified in T::*pfn. Then you can work with this delegate directly to attach its event handler to an event on a particular object. This version of CreateDelegate creates a reference counted object with an initial reference count of 1. It is the responsibility of the caller to release this object.

To attach the associated event handler to an event on a particular object, you can attach the returned delegate to that object. To do this, use the return value as an input parameter for methods that add delegates to UI objects such as objects derived from IXRFrameworkElement. If you have attached the event handler to a UI object, the UI object will use the delegate to invoke the event handler every time that the object raises the event.

.NET Framework Equivalent

None.

Requirements

Header

XRDelegate.h

sysgen

SYSGEN_XAML_RUNTIME

See Also

Reference

CreateDelegate
CreateDelegate(class,class::method)
XAML for Windows Embedded Functions