zoukankan      html  css  js  c++  java
  • 关闭ShowDialog的模态窗口

     [DllImport("user32.dll")]
            private static extern IntPtr FindWindow(string a, string b);
    
            [DllImport("user32.dll")]
            private static extern IntPtr PostMessage(IntPtr hWnd, int msg, IntPtr wp, IntPtr lp);
    
       Timer timer = new Timer();
                timer.Tick += (obj, arg) =>
                    {
                        //1、尝试关闭ColorDialog
                        IntPtr ptr1 = FindWindow(null, "颜色");
                        if (ptr1 != IntPtr.Zero)
                        {
                            PostMessage(ptr1, 0x0010, IntPtr.Zero, IntPtr.Zero);
                            SetInfoBar("ColorDialog已关闭");
                        }
                        //2、尝试关闭FolderBrowserDialog
                        IntPtr ptr2 = FindWindow(null, "浏览文件夹");
                        if (ptr2 != IntPtr.Zero)
                        {
                            PostMessage(ptr2, 0x0010, IntPtr.Zero, IntPtr.Zero);
                            SetInfoBar("FolderBrowserDialog已关闭");
                        }
                        //3、尝试关闭FontDialog
                        IntPtr ptr3 = FindWindow(null, "字体");
                        if (ptr3 != IntPtr.Zero)
                        {
                            PostMessage(ptr3, 0x0010, IntPtr.Zero, IntPtr.Zero);
                            SetInfoBar("FontDialog已关闭");
                        }
                        //4、尝试关闭OpenFileDialog
                        IntPtr ptr4 = FindWindow(null, "打开");
                        if (ptr4 != IntPtr.Zero)
                        {
                            PostMessage(ptr4, 0x0010, IntPtr.Zero, IntPtr.Zero);
                            SetInfoBar("OpenFileDialog已关闭");
                        }
                        //5、尝试关闭SaveFileDialog
                        IntPtr ptr5 = FindWindow(null, "另存为");
                        if (ptr5 != IntPtr.Zero)
                        {
                            PostMessage(ptr5, 0x0010, IntPtr.Zero, IntPtr.Zero);
                            SetInfoBar("SaveFileDialog已关闭");
                        }
                        //6、尝试关闭MessageBox
                        IntPtr ptr6 = FindWindow(null, "测试消息");
                        if (ptr6 != IntPtr.Zero)
                        {
                            PostMessage(ptr6, 0x0010, IntPtr.Zero, IntPtr.Zero);
                            SetInfoBar("MessageBox已关闭");
                        }
                        //7、尝试关闭自定义窗口(Show)
                        IntPtr ptr7 = FindWindow(null, "自定义窗口(Show)");
                        if (ptr7 != IntPtr.Zero)
                        {
                            PostMessage(ptr7, 0x0010, IntPtr.Zero, IntPtr.Zero);
                            SetInfoBar("自定义窗口(Show)已关闭");
                        }
                        //8、尝试关闭自定义窗口(ShowDialog)
                        IntPtr ptr8 = FindWindow(null, "自定义窗口(ShowDialog)");
                        if (ptr8 != IntPtr.Zero)
                        {
                            PostMessage(ptr8, 0x0010, IntPtr.Zero, IntPtr.Zero);
                            SetInfoBar("自定义窗口(ShowDialog)已关闭");
                        }
                    };
                timer.Interval = 5000;
                timer.Enabled = true;
                timer.Start();
    
  • 相关阅读:
    easyUI日期框,默认显示今天,今天以后的日期不能选
    vue实现下拉框全选和输入匹配
    【转载】CSS flex属性深入理解
    ES6学习之二
    Centos7(Firewall)防火墙命令
    DeDeCMS模板标签(2)
    DeDeCMS模板标签(1)
    常用js正则表达式大全
    linux yum 命令
    Linux软链接和硬链接
  • 原文地址:https://www.cnblogs.com/xiangxiong/p/6477653.html
Copyright © 2011-2022 走看看