private bool EnumWindowsCallback(IntPtr window, IntPtr lParam) { if (!this.onlyTopLevel || WinLib.isTopLevelWindow(window)) { this.windows.Add(window); } return(true); }
public static void drawRectangle(int x, int y) { Point point = new Point(x, y); Pen pen = new Pen(Config.Instance.gazePositionColor, 2); SolidBrush brush = new SolidBrush(Config.Instance.gazePositionColor); IntPtr desktopPtr = WinLib.GetDC(IntPtr.Zero); Graphics g = Graphics.FromHdc(desktopPtr); Rectangle rect = new Rectangle(point, new Size(30, 30)); g.FillRectangle(brush, rect); g.DrawRectangle(pen, rect); }
public static bool isTopLevelWindow(IntPtr window) { bool ret = false; Process process = WinLib.getProcess(window); if (window != IntPtr.Zero && !IsIconic(window) && IsWindowVisible(window)) { Rectangle rect = new Rectangle(); GetWindowRect(window, out rect); if (rect.Width > 0 && rect.Height > 0) { ret = true; } } return(ret); }