Exemplo n.º 1
0
        private void hwndText_TextChanged(object sender, TextChangedEventArgs e)
        {
            IntPtr hwnd;

            if (IsIntPtr(hwndText.Text, 16) && (hwnd = Hwnd) != IntPtr.Zero && WinUser.IsWindow(hwnd) && hwnd != Handle)
            {
                s_hButton.IsEnabled = true;
                s_hButton.IsChecked = WinUser.IsWindowVisible(hwnd);
                e_dButton.IsEnabled = true;
                e_dButton.IsChecked = WinUser.IsWindowEnabled(hwnd);

                gotoNextButton.IsEnabled = NextWindow(hwnd) != IntPtr.Zero ? true : false;
                gotoPrevButton.IsEnabled = PrevWindow(hwnd) != IntPtr.Zero ? true : false;
                AddHandle(hwnd);

                StringBuilder strb = new StringBuilder(256);
                WinUser.GetWindowText(hwnd, strb, 256);
                string title = strb.ToString();
                this.Title = string.Format("{0} - {1}", assemblyName.Name, title);
            }
            else
            {
                WhenNullHandle();
            }
        }
Exemplo n.º 2
0
        public string GetControlText(IntPtr hWnd)
        {
            StringBuilder title = new StringBuilder(256);

            // Get the size of the string required to hold the window title.
            Int32 size = WinUser.SendMessage(hWnd, (int)WindowMessage.WM_GETTEXTLENGTH, 0, 0);

            // If the return is 0, there is no title.
            if (size > 0)
            {
                title = new StringBuilder(size + 1);
                WinUser.SendMessage(hWnd, (int)WindowMessage.WM_GETTEXT, title.Capacity, title);
            }
            else
            {
                WinUser.GetWindowText(hWnd, title, title.Capacity);
            }

            return(title.ToString());
        }