Partager via


CreateDelegate(class,class::method) (Windows Embedded CE 6.0)

1/6/2010

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>
IXRDelegate<ArgType>* CreateDelegate(
    T* pT, 
    HRESULT (T::*pfn)(IXRDependencyObject*, ArgType*)
)

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 creates a delegate for an OnMouseMove event handler implemented in an object named CustomEventHandler:

    &CustomEventHandler::OnMouseMove
    

Return Value

Returns an IXRDelegate<ArgType> template class that Silverlight for Windows Embedded has customized for the event handler you specify in T::*pfn.

Remarks

This version of the CreateDelegate function is used inline when you call an Add*EventHandler method. For example:

TestEventHandler HandlerObject;
pIButton->AddMouseEnterEventHandler(CreateDelegate(&HandlerObject, &TestEventHandler::OnMouseEnter));

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. Now you can work with this delegate directly, to attach its event handler to an event on a particular 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
Windows Embedded CE Windows Embedded CE 6.0 R3

See Also

Reference

CreateDelegate
CreateDelegate(class,class::method,IXRDelegate<ArgType>)
Silverlight for Windows Embedded Functions

Concepts

Handle Events in Silverlight for Windows Embedded