• C# WPF 让你的窗口始终钉在桌面上


                IntPtr hWnd = new WindowInteropHelper(Application.Current.MainWindow).Handle;
                IntPtr hWndProgMan = FindWindow("Progman", "Program Manager");
                SetParent(hWnd, hWndProgMan);
    

      

            [DllImport("user32.dll", SetLastError = true)]
            static extern int SetWindowLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong);
            [DllImport("user32.dll", SetLastError = true)]
            static extern IntPtr FindWindow(string lpWindowClass, string lpWindowName);
            [DllImport("user32.dll", SetLastError = true)]
            static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr childAfter, string className, string windowTitle);
            const int GWL_HWNDPARENT = -8;
            [DllImport("user32.dll")]
            static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);
    

      

     var handle = new WindowInteropHelper(Application.Current.MainWindow).Handle;
                IntPtr hprog = FindWindowEx(
                    FindWindowEx(
                        FindWindow("Progman", "Program Manager"),
                        IntPtr.Zero, "SHELLDLL_DefView", ""
                    ),
                    IntPtr.Zero, "SysListView32", "FolderView"
                );
                SetWindowLong(handle, GWL_HWNDPARENT, hprog);
    

      

  • 相关阅读:
    java 接口中的成员变量与方法
    Spring BeanPostProcessor
    MySQL更改命令行默认分隔符
    java 动态代理
    《剑指offer》:[62]序列化二叉树
    group by语法
    Mysql两种引擎
    线程池大小设置
    Synchronized及其实现原理
    CAS ABA问题
  • 原文地址:https://www.cnblogs.com/liulun/p/4997825.html
Copyright © 2020-2023  润新知