Beispiel #1
0
        private static bool MyEnumDesktopWindows(IntPtr hwnd, IntPtr lParam)
        {
            IntPtr threadId = GetWindowThreadProcessId(hwnd, 0);
            IntPtr desk     = GetThreadDesktop(threadId);

            CloseDesktop(desk);
            if (desk == lParam)
            {
                WindowInformation info = new WindowInformation(hwnd);
                if (info.Visible == false)
                {
                    return(true);
                }
                string title = info.Text;
                if (title == null || title.Length == 0)
                {
                    return(true);
                }
                myDesktopWindows.Add(info);
                //return true;
            }
            else
            {
                //return false;
            }
            return(true);
        }
Beispiel #2
0
 /// <summary>
 /// 安全的根据窗体句柄创建对象
 /// </summary>
 /// <param name="handle">窗体句柄对象</param>
 /// <returns>获得的窗体信息对象,若句柄无效则返回空引用</returns>
 public static WindowInformation FromHandle(System.IntPtr handle)
 {
     if (CheckHandle(handle))
     {
         WindowInformation info = new WindowInformation(handle);
         return(info);
     }
     else
     {
         return(null);
     }
 }
Beispiel #3
0
        /// <summary>
        /// 获得顶级父窗体对象
        /// </summary>
        /// <returns>获得的顶级父窗体对象</returns>
        public WindowInformation GetTopLevelParentWindow()
        {
            WindowInformation[] ws   = DesktopWindows;
            WindowInformation   info = this;

            while (info != null)
            {
                foreach (WindowInformation w in ws)
                {
                    if (w.Handle == info.Handle)
                    {
                        return(w);
                    }
                }
                info = info.Parent;
            }
            return(null);
        }