• WPF窗体置于桌面最底层


    在WPF中设置窗体的Topmost属性可以将窗体永远置于顶部,但是没有提供Bottommost属性将窗体置底。若果要将窗体置于桌面的最底部,就需要使用Windows API来实现了。解决方案如下:

    1,引入Windows API 

    [DllImport("user32.dll")]
    public static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X,int Y, int cx, int cy, uint uFlags);

    public const UInt32 SWP_NOSIZE = 0x0001;
    public const UInt32 SWP_NOMOVE = 0x0002;
    public const UInt32 SWP_NOACTIVATE = 0x0010;
    public static readonly IntPtr HWND_BOTTOM = new IntPtr(1);

    2,使用API

    private void SetBottom(Window window)
    {
    IntPtr hWnd = new WindowInteropHelper(window).Handle;
    Win32.SetWindowPos(hWnd, Win32.HWND_BOTTOM, 0, 0, 0, 0, Win32.SWP_NOSIZE | Win32.SWP_NOMOVE | Win32.SWP_NOACTIVATE);
    }

    3,将WCF窗体置底

    在窗体看的Activated和StateChanged两个事件中都调用 SetBottom方法

  • 相关阅读:
    数据库存储语句
    数据库练习总结
    数据库练习
    数据库增添
    数据库创建
    cookie 和 session的区别 & 三种传值方式
    内置对象——cookie
    webform跨页面传值
    复合控件
    repeater(控件)数据展示
  • 原文地址:https://www.cnblogs.com/moonlight-zjb/p/3442298.html
Copyright © 2020-2023  润新知