How to check if a Win32 window pointer is a valid .Net Control?

How to check if a Win32 window pointer is a valid .Net Control?

+3
source share
1 answer

I'm going to suggest that with "Win32 Window Pointer" you mean hWnd.

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

The pseudocode is as follows:

Control AssociatedDotNetControl = 
    Control.FromChildHandle(Win32WindowPointerAshWnd);

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

Source: https://habr.com/ru/post/1716679/


All Articles