您如何将 WinForms 表单放在桌面图标后面但在墙纸前面?为了使桌面成为表单的父级,我使用:
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
[DllImport("user32.dll", SetLastError = true)]
static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
IntPtr desktopHandle = (IntPtr)FindWindow("Progman", null);
WallForm wallWindow = new WallForm();//WinForms Form
...
private void SwitchParent()
{
wallWindow.Show();
SetParent(wallWindow.Handle, desktopHandle);
//wallWindow.SendToBack();
}
这可行,但它将表单放在桌面图标的前面。如果我在表单上调用 SendToBack,它就会消失,大概是在墙纸后面。我怎样才能让表单位于图标和桌面背景之间?