首页 > Windows开发 > 详细

窗体句柄的简单封装及激活指定的窗体

时间:2014-12-26 12:42:45      阅读:326      评论:0      收藏:0      [点我收藏+]
        private static void ActivateOtherWindow(string windowName)
        {
            var other = FindWindow(null, windowName);
            if (other != IntPtr.Zero)
            {
                SetForegroundWindow(other);
                if (IsIconic(other))
                    OpenIcon(other);
            }
        }
        
        [DllImport("user32", CharSet = CharSet.Unicode)]
        static extern IntPtr FindWindow(string cls, string win);
        [DllImport("user32")]
        static extern IntPtr SetForegroundWindow(IntPtr hWnd);
        [DllImport("user32")]
        static extern bool IsIconic(IntPtr hWnd);
        [DllImport("user32")]
        static extern bool OpenIcon(IntPtr hWnd);

 

窗体句柄的简单封装及激活指定的窗体

原文:http://www.cnblogs.com/3Tai/p/4186393.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!