共用方式為


HwndSource.FromHwnd(IntPtr) 方法

定義

回傳 HwndSource 指定視窗的物件。

public:
 static System::Windows::Interop::HwndSource ^ FromHwnd(IntPtr hwnd);
[System.Security.SecurityCritical]
public static System.Windows.Interop.HwndSource FromHwnd(IntPtr hwnd);
public static System.Windows.Interop.HwndSource FromHwnd(IntPtr hwnd);
[<System.Security.SecurityCritical>]
static member FromHwnd : nativeint -> System.Windows.Interop.HwndSource
static member FromHwnd : nativeint -> System.Windows.Interop.HwndSource
Public Shared Function FromHwnd (hwnd As IntPtr) As HwndSource

參數

hwnd
IntPtr

nativeint

提供的窗戶把手。

傳回

HwndSource 視窗控制柄指定的 hwnd 視窗物件。

屬性

備註

這很重要

此方法在網際網路安全區域或部分信任系統中不可用。

你可以用這個方法回傳 HwndSource 一個不是明確互操作視窗的視窗。 此程序如下:

  1. 建立一個 WindowInteropHelper 實例(提供主 Window 實例作為建構參數)。

  2. 從該WindowInteropHelper案例中取得該Handle物業的價值。

  3. 將該 HWND 值作為參數傳給 FromHwnd

如果你想在視窗中加入一般 AddHook 性的訊息處理,這個技術會很有用。 然而,當你創造 時 HwndSource,你也必須負責銷毀它。 即使ApplicationHwndSource應用物件被處置,這點仍然成立。 欲了解更多資訊,請參閱 的備註 HwndSource

適用於

另請參閱