如何发送WPF窗口到后面?
答
是否有任何特殊的原因,您不希望以最小化状态显示窗口并允许用户显示它?如果显示在最小化状态的窗口解决您的问题,使用
<Window WindowState="Minimized" (...)>
答
您可以使用下面的代码:
[DllImport("user32.dll")]
static extern bool SetWindowPos(
IntPtr hWnd,
IntPtr hWndInsertAfter,
int X,
int Y,
int cx,
int cy,
uint uFlags);
const UInt32 SWP_NOSIZE = 0x0001;
const UInt32 SWP_NOMOVE = 0x0002;
static readonly IntPtr HWND_BOTTOM = new IntPtr(1);
static void SendWpfWindowBack(Window window)
{
var hWnd = new WindowInteropHelper(window).Handle;
SetWindowPos(hWnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
}
来源:http://www.aeroxp.org/board/lofiversion/index.php?t4983.html
+0
哇......我确定会有一班人来照顾那个...... – 2009-07-27 05:57:27
我希望窗口是从一开始开放背景。感谢您的建议,但它不能帮助我。 – 2009-07-25 06:47:23