Example #1
0
        public static bool DoesWindowBelongToProcess(IntPtr hWnd, int processId)
        {
            int winProcessId = 0;

            WindowAction.GetWindowThreadProcessId(hWnd, out winProcessId);
            return(winProcessId == processId);
        }
Example #2
0
        private static bool EnumTopWindows(IntPtr hWnd, IntPtr lParam)
        {
            int winProcessId = 0;

            WindowAction.GetWindowThreadProcessId(hWnd, out winProcessId);

            if (!IsWindow(hWnd) ||
                !WindowAction.IsWindowVisible(hWnd) ||
                hWnd == WindowAction.statusbar
                )
            {
                return(true);
            }

            GCHandle      gch = (GCHandle)lParam;
            ProcessHWinds phw = (ProcessHWinds)(gch.Target);

            if (!DoesWindowBelongToProcess(hWnd, phw.processId))
            {
                return(true);
            }

            phw.topWinds.Add(hWnd);

            return(true);
        }
Example #3
0
        public static string GetWindowClassReal(IntPtr hWnd)
        {
            StringBuilder sb = new StringBuilder(255);

            WindowAction.RealGetWindowClass(hWnd, sb, 255);
            return(sb.ToString());
        }
Example #4
0
        public static string GetWindowText(IntPtr hWnd)
        {
            StringBuilder sb = new StringBuilder(255);

            WindowAction.GetWindowText(hWnd, sb, 255);
            return(sb.ToString());
        }
Example #5
0
 public static bool IsValidWindow(IntPtr hWnd)
 {
     if (!WindowAction.IsWindowVisible(hWnd) || hWnd == WindowAction.statusbar || !WindowAction.IsWindow(hWnd))
     {
         return(false);
     }
     return(true);
 }
Example #6
0
 public static void HighlightWindow(IntPtr hWnd, Highlighter h)
 {
     if (hWnd.ToInt32() == 0)
     {
         return;
     }
     WindowAction.RECT rect = new WindowAction.RECT();
     WindowAction.GetWindowRect(hWnd, out rect);
     h.Flash(WindowAction.RECT.ToRectangle(rect));
 }
Example #7
0
        public static IntPtr GetMenuHandle(IntPtr hWnd)
        {
            IntPtr hMenu = GetMenu(hWnd);

            if (hMenu == IntPtr.Zero)
            {
                hMenu = (IntPtr)WindowAction.SendMessage(hWnd, MN_GETHMENU, IntPtr.Zero, IntPtr.Zero);
            }

            return(hMenu);
        }
Example #8
0
        public WindowInfo(IntPtr hWnd)
        {
            this.Hwnd = hWnd;

            this.ClassName = WindowAction.GetWindowClassName(hWnd);

            int winProcessId = 0;

            this.Tid = WindowAction.GetWindowThreadProcessId(hWnd, out winProcessId);
            this.Pid = winProcessId;

            this.ProcessName = Process.GetProcessById(winProcessId).ProcessName;
            this.WindowText  = WindowAction.GetWindowText(hWnd);
        }
Example #9
0
        public static Rectangle GetMenuItemRect(IntPtr hWnd, IntPtr hMenu, uint uItem)
        {
            Rectangle mrect = Rectangle.Empty;

            MadPiranha.Plugster.Util.WindowAction.RECT rect = new MadPiranha.Plugster.Util.WindowAction.RECT();
            if (GetMenuItemRect(hWnd, hMenu, uItem, ref rect))
            {
                mrect = new Rectangle(rect.Left, rect.Top, rect.Right - rect.Left, rect.Bottom - rect.Top);

                MadPiranha.Plugster.Util.WindowAction.RECT winRect = new MadPiranha.Plugster.Util.WindowAction.RECT();

                if (WindowAction.IsWindowMirrored(hWnd) && WindowAction.GetWindowRect(hWnd, out winRect) != 0)
                {
                    int dist = mrect.Left - winRect.Left;
                    mrect = new Rectangle(winRect.Right - dist - mrect.Width,
                                          mrect.Y,
                                          mrect.Width,
                                          mrect.Height);
                }
            }

            return(mrect);
        }