Share via


IXRWin32Control::SetHandle (Compact 2013)

3/28/2014

This method sets an existing window handle as the new handle for an IXRWin32Control object, so that the IXRWin32Control object represents a child window control of the visual host window.

Syntax

virtual HRESULT STDMETHODCALLTYPE SetHandle(
    HWND Handle, 
    boolDestroyPreviousWindow
) = 0; 

Parameters

  • DestroyPreviousWindow
    [in] Boolean that indicates whether to send a WM_DESTROY message to the previous window for this control and destroy its handle before XAML for Windows Embedded sets the new handle.

Return Value

Returns an HRESULT that indicates success or failure.

Remarks

Before this method sets the HWND specified in Handle, it removes any previous handle to this window control from the cache and sets the handle to its parent window to Null.

XAML for Windows Embedded uses the DestroyPreviousWindow parameter when it replaces one Win32 control handle with another one at run time. For example, consider a predefined Win32 control defined in the source XAML. At run time, if you have some programming logic that replaces the predefined Win32 control with a new Win32 control and you no longer need the predefined Win32 control in your application, you can call SetHandle to replace the predefined Win32 control with the new one, passing in DestroyPreviousWindow as true in order to destroy the predefined Win32 window handle.

When this occurs, the new Win32 control with the new handle automatically goes into the exact same location as the predefined control in the visual tree and inherits all existing behaviors for the predefined Win32 control, such as animation storyboards.

.NET Framework Equivalent

None.

Requirements

Header

XamlRuntime.h

sysgen

SYSGEN_XAML_RUNTIME

See Also

Reference

IXRWin32Control
IXRWin32Control::GetHandle