/// <summary> /// Highlights the specified window, if valid. /// </summary> private void HighlightValidWindow(IntPtr hWnd, IntPtr hOwner) { // Check for valid highlight if (targetedWindowHandle == hWnd) { return; } // Check for relative if (Win32Ex.IsRelativeWindow(hWnd, hOwner, true)) { // Unhighlight last window if (targetedWindowHandle != IntPtr.Zero) { Win32Ex.HighlightWindow(targetedWindowHandle); targetedWindowHandle = IntPtr.Zero; } return; } // Unhighlight last window Win32Ex.HighlightWindow(targetedWindowHandle); // Set as current target targetedWindowHandle = hWnd; // Highlight window Win32Ex.HighlightWindow(hWnd); }
/// <summary> /// Shows the information of the window with the specified handle. /// </summary> private void ShowWindowInfo(IntPtr hWnd, bool handle) { if ((Win32.IsWindow(hWnd) == 0) || (Win32Ex.IsRelativeWindow(hWnd, Handle, true))) { if (handle) { textHandle.Text = ""; } textCaption.Text = ""; textCharset.Text = ""; return; } // Set window information if (handle) { textHandle.Text = Convert.ToString(hWnd.ToInt32(), 16).ToUpper().PadLeft(8, '0'); } textCaption.Text = Win32Ex.GetWindowText(hWnd); textCharset.Text = ((Win32.IsWindowUnicode(hWnd) != 0) ? ("Unicode") : ("Ansi")); }