c# – 如何发送一个WPF窗口到后面?
发布时间:2020-12-15 06:54:22 所属栏目:百科 来源:网络整理
导读:在我的应用程序中,我有一个窗口用于绘制调试数据.当它加载时,我想打开它“在后台”,在所有其他窗口后面. 什么是实现这一目标的最佳方法? 解决方法 您可以使用以下代码: [DllImport("user32.dll")]static extern bool SetWindowPos( IntPtr hWnd,IntPtr hWn
|
在我的应用程序中,我有一个窗口用于绘制调试数据.当它加载时,我想打开它“在后台”,在所有其他窗口后面.
什么是实现这一目标的最佳方法? 解决方法
您可以使用以下代码:
[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,SWP_NOSIZE | SWP_NOMOVE);
}
资料来源:http://www.aeroxp.org/board/lofiversion/index.php?t4983.html (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
