我的代码是
private static readonly IntPtr HWND_BOTTOM = new IntPtr(1);
private const UInt32 SWP_NOSIZE = 0x0001;
private const UInt32 SWP_NOMOVE = 0x0002;
private const UInt32 BOTTOM_FLAGS = SWP_NOSIZE;
...
private void Form1_Load(object sender, EventArgs e)
{
SetWindowPos(this.Handle, HWND_BOTTOM, 0, 0, 0, 0, BOTTOM_FLAGS);
}
它应该在所有其他窗口的后面,如 https://docs.microsoft.com/en-gb/windows/win32/api/winuser/nf-winuser-setwindowpos?redirectedfrom=MSDN 所述。
但是,它会出现在所有其他窗口的前面,并且需要单击其他窗口才能进入前面。
回答1
解决方案是添加更多标志并将我的一些代码移动到 WndProc,如评论中所示。