I've imported:
public static extern IntPtr SetParent(
IntPtr hWndChild, // handle to window
IntPtr hWndNewParent // new parent window
);
from user32.dll
in my windows forms application and continuously setting SetParent(hwndf,hwndParent);
(if a variable is true) in a background thread.
Where
IntPtr hwndf = Control.Handle;
IntPtr hwndParent = FindWindow("ProgMan", null);
My question How do i reset the parent handle to be the default windows form handle, aka, how do I not display the window on top of the desktop window anymore? and is following, Is this an efficient way of doing this (repeatedly?).
Never mind. I could just use
SetParent(hwndf, new IntPtr(0));
When I wanted to "reset" the form window parent. The only problem was the the window was minimized, so my solution was running ShowWindow(hwndf, SW_RESTORE);
after importing these methods from user32.dll
!
[DllImport("user32.dll")]
public static extern IntPtr ShowWindow(
IntPtr hWnd, // handle to window
uint nCmdShow
);
private const uint SW_RESTORE = 0x09;