I\'m creating a desktop gadget, and am running into problems. The window will be hidden by the \"Show Desktop\" command - STOP, I know what you\'re thinking and don\'t need
Maybe a bit late for an answer to your question, but nevertheless here the answer, which I seem to have found:
[System.Runtime.InteropServices.DllImport("user32.dll", SetLastError = true)]
static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
[System.Runtime.InteropServices.DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindowEx(IntPtr hP, IntPtr hC, string sC, string sW);
void MakeWin()
{
IntPtr nWinHandle = FindWindowEx(IntPtr.Zero, IntPtr.Zero, "Progman", null);
nWinHandle = FindWindowEx(nWinHandle, IntPtr.Zero, "SHELLDLL_DefView", null);
SetParent(Handle, nWinHandle);
}
"MakeWin" should be called in the Constructor of the Form, best before "InitializeComponent". Works good for me at least under Win7.