简体   繁体   中英

How can I check if a Win32 Window pointer is a valid .Net Control?

如何检查Win32窗口指针是否是有效的.Net控件?

I'm going to assume that, by "Win32 Window pointer", you mean an hWnd.

You can call Control.FromChildHandle() supplying your hWnd as a parameter. If the hWnd is associated with a .NET Control, then you will receive, as a return value, a reference to the .NET Control representing the control. If the hWnd is not associated with a .NET Control, then you will receive, as a return value, a value of null.

Pseudocode is as follows:

Control AssociatedDotNetControl = 
    Control.FromChildHandle(Win32WindowPointerAshWnd);

if(AssociatedDotNetControl != null)
{
    // this is a .NET control
}
else
{
    // this is not a .NET control
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM