zoukankan      html  css  js  c++  java
  • C#调用API 实现窗体总在最上

    class Win32
            {
                [DllImport("user32.dll", EntryPoint = "SetWindowPos")]
                public static extern bool SetWindowPos(
                    int hWnd,               // window handle     
                    int hWndInsertAfter,    // placement-order handle     
                    int X,                  // horizontal position     
                    int Y,                  // vertical position     
                    int cx,                 // width     
                    int cy,                 // height     
                    uint uFlags);           // window positioning flags  
                public const int HWND_BOTTOM = 0x1;
                public const uint SWP_NOSIZE = 0x1;
                public const uint SWP_NOMOVE = 0x2;
                public const uint SWP_SHOWWINDOW = 0x40;
            }

            private void ShoveToBackground()
            {
                Win32.SetWindowPos((int)this.Handle, -1, this.Location.X, this.Location.Y, this.Size.Width, this.Size.Height, 1);

                //Win32.SetWindowPos(
                //    (int)this.Handle,
                //    (int),
                //    0, 0, 0, 0,
                //    Win32.SWP_NOMOVE | Win32.SWP_NOSIZE | Win32.HWND_BOTTOM);
            }

            private void Bar_Activated(object sender, EventArgs e)
            {
                //总在最上
                ShoveToBackground();
            }
            private void Bar_Leave(object sender, EventArgs e)
            {
                //总在最上
                ShoveToBackground();
            }

  • 相关阅读:
    淘宝API学习之道:淘宝TOP之API接口接入教程
    hdu 2952 Counting Sheep
    【Java 虚拟机探索之路系列】:JIT编译器
    Android Afinal框架学习(一) FinalDb 数据库操作
    class、interface、struct的差别
    13个Cat命令管理文件实例汇总
    Linux df 命令用法示例
    九个uname命令获取Linux系统详情的实例
    Linux中查看进程的多线程
    精通Linux的“kill”命令
  • 原文地址:https://www.cnblogs.com/yinhaosln/p/1504482.html
Copyright © 2011-2022 走看看