zoukankan      html  css  js  c++  java
  • C# window 窗体 保持最前显示

    两句话搞定
    [DllImport("user32.dll", CharSet = CharSet.Auto)]
     private static extern int SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int y, int Width, int Height, int flags);

      SetWindowPos(this.Handle, -1, 0, 0, 0, 0, 1 | 2); 

    namespace test
    {
        public partial class Form1 : Form
        {
            [DllImport("user32.dll", CharSet = CharSet.Auto)]
            private static extern int SetWindowPos(IntPtr hWnd, int hWndInsertAfter, int x, int y, int Width, int Height, int flags);
    
            public Form1()
            {
                InitializeComponent(); 
            }
    
             protected override void OnLoad(EventArgs e)    
             {
                 SetWindowPos(this.Handle, -1, 0, 0, 0, 0, 1 | 2); //最后参数也有用1 | 4 p1.MainForm.Handle  我记得这个是MainForm吧  反正是主窗口
                 SetWindowPos(this.printPreviewDialog1.Handle, -1, 0, 0, 0, 0, 1 | 2); //最后参数也有用1 | 4 p1.MainForm.Handle  我记得这个是MainForm吧  反正是主窗口
             
             }
        }
    }
  • 相关阅读:
    Redis 安装
    Git的安装和使用
    HTML5 本地存储+layer弹层组件制作记事本
    PHP 微信公众号开发
    PHP 微信公众号开发
    Electron 安装与使用
    HTML5 桌面消息提醒
    Composer安装和使用
    玄 学
    区间内的真素数
  • 原文地址:https://www.cnblogs.com/su-king/p/5122051.html
Copyright © 2011-2022 走看看