如何发送一个WPF窗口后面? [英] How to send a WPF window to the back?

查看:125
本文介绍了如何发送一个WPF窗口后面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用我有我用于绘制调试数据的窗口。当它加载,我想在后台打开它,后面的所有其他窗口。

In my application I have a window I use for plotting debug data. When it loads, I would like to open it "in the background", behind all other windows.

什么是实现这一目标的最佳方式是什么?

What's the best way to achieve this?

推荐答案

您可以使用下面的code:

You can use the following code:

[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);
}

来源:<一href="http://www.aeroxp.org/board/lofiversion/index.php?t4983.html">http://www.aeroxp.org/board/lofiversion/index.php?t4983.html

这篇关于如何发送一个WPF窗口后面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆