码迷,mamicode.com
首页 > Windows程序 > 详细

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

时间:2014-12-26 12:45:51      阅读:207      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!