次の方法で共有


IXRVisualHost::GetContainerHWND (Compact 2013)

3/28/2014

This method obtains a handle (HWND) to the operating-system (OS) window that provides the foundation for this visual host.

Use the GetContainerHWND method with caution because the handle you obtain from it is also shared with the XAML for Windows Embedded system.

Syntax

virtual HRESULT STDMETHODCALLTYPE GetContainerHWND(
    HWND* pHwnd
) = 0;

Parameters

  • pHwnd
    [out] Handle to the window that provides the foundation for this visual host.

Return Value

Returns an HRESULT that indicates success or failure.

Returns XR_E_INVALID_THREAD_ACCESS if this method was called from a thread different from the thread on which the system was initialized. A visual host can only be accessed on the thread that it was created on. Notice that most XAML for Windows Embedded APIs can only be accessed from a single thread.

Returns XR_E_INVALID_STATE if this method was called on an object in an invalid state, such as a host that was already destroyed, or a dialog that was closed without calling EndDialog.

Remarks

If you plan to use the HWND for the foundational window, you should call this method first before you execute other functionality of the visual host such as obtaining the root element by calling IXRVisualHost::GetRootElement, or showing the visual host and rendering the element tree on-screen by calling IXRVisualHost::ShowWindow.

Be careful when you use the HWND to execute functionality. This HWND is also used internally by XAML for Windows Embedded to set up the windows procedure, store values in the storage region of the window, and manage the creation and destruction of the window. Make sure that you do not execute functionality that interferes with these tasks. While exercising caution, you can use this HWND together with methods such as those listed in GDI Functions for implementing custom functionality.

The HWND obtained by this method can be useful for migrating a legacy application to XAML for Windows Embedded.

.NET Framework Equivalent

None.

Requirements

Header

XamlRuntime.h

sysgen

SYSGEN_XAML_RUNTIME

See Also

Reference

IXRVisualHost