there is a WinAPI function SetParent
HWND WINAPI SetParent( _In_ HWND hWndChild, _In_opt_ HWND hWndNewParent ); Return value
Type: HWND
If the function succeeds, the return value is the handle to the previous parent window.
If the function fails, the return value is NULL. For more information, call GetLastError.
I use pinvoke wrapper from the corresponding site.
[DllImport("user32.dll", SetLastError = true)] static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent); How can I check that the function returned NULL ?