Control.FromChildHandle(IntPtr) 方法

定義

擷取包含指定控制代碼的控制項。Retrieves the control that contains the specified handle.

public:
 static System::Windows::Forms::Control ^ FromChildHandle(IntPtr handle);
public static System.Windows.Forms.Control FromChildHandle (IntPtr handle);
static member FromChildHandle : nativeint -> System.Windows.Forms.Control
Public Shared Function FromChildHandle (handle As IntPtr) As Control

參數

handle
IntPtr

要搜尋的視窗控制代碼 (HWND)。The window handle (HWND) to search for.

傳回

Control

Control,表示與指定的控制代碼關聯的控制項。如果找不到具有指定控制代碼的控制項,會傳回 nullThe Control that represents the control associated with the specified handle; returns null if no control with the specified handle is found.

備註

這個方法會搜尋視窗控制碼父鏈,直到找到與控制項相關聯的控制碼為止。This method searches up the window handle parent chain until it finds a handle that is associated with a control. 這個方法比 FromHandle 方法更可靠,因為它會正確傳回擁有一個以上控制碼的控制項。This method is more reliable than the FromHandle method, because it correctly returns controls that own more than one handle.

適用於

另請參閱