コード例 #1
0
        private static void GetWindowInfo(IntPtr hWnd, bool isInFocus = false)
        {
            // http://www.codeproject.com/Articles/1698/MS-Spy-style-Window-Finder
            if (hWnd != IntPtr.Zero && WinApi.IsWindow(hWnd) && hWnd != hWndFoundWindow)
            {
                WindowSelectorEventArgs e = new WindowSelectorEventArgs();

                //Программа
                int pId;
                var threadId = WinApi.GetWindowThreadProcessId(hWnd, out pId);
                using (var p = Process.GetProcessById(pId))
                    e.ProgramName = p.MainModule.ModuleName;

                if (isInFocus)
                {
                    e.HGetForegroundWindow = (int)hWnd;
                    var h = Misc.GetFocusedHandle(threadId, e);
                    if (h != IntPtr.Zero)
                    {
                        hWnd = h;
                    }
                    if (hWnd == hWndFoundWindow)
                    {
                        return;
                    }
                }

                //Класс
                var temp = new StringBuilder(256);
                WinApi.GetClassName(hWnd, temp, temp.Capacity);
                e.ClassName = temp.ToString();
                temp.Clear();

                //Заголовок
                temp.Capacity = 256;
                WinApi.GetWindowText(hWnd, temp, temp.Capacity);
                e.WindowCaption = temp.ToString();
                temp.Clear();

                //Дескриптор
                e.HWindow = (int)hWnd;
                e.HParent = (int)WinApi.GetParent(hWnd);

                //Очищаем
                RefreshWindow(hWndFoundWindow);

                //Рисуем прямоугольник
                HighlightFoundWindow(hWnd);

                hWndFoundWindow = hWnd;

                if (UiUpdate != null)
                {
                    UiUpdate.Invoke(null, e);
                }
            }
        }
コード例 #2
0
 protected virtual void OnUiUpdate(string message, bool isError, bool append, EventArgs e)
 {
     UiUpdate?.Invoke(this, message, isError, append, e);
 }
コード例 #3
0
 private void DeviceNotifcation(object sender, string message, bool isCritical, EventArgs e)
 {
     UiUpdate?.Invoke(sender, message, isCritical, true, e);
 }