mirror of
https://github.com/greenshot/greenshot
synced 2025-07-15 01:23:47 -07:00
Small code optimization in GetActiveWindow, and bugfix in an unused method GetWindow (used for testing)
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2122 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
21d273a8c3
commit
568264a045
1 changed files with 8 additions and 1 deletions
|
@ -488,6 +488,9 @@ namespace GreenshotPlugin.Core {
|
|||
/// <returns>null if nothing found, otherwise the WindowDetails instance of the "child"</returns>
|
||||
public WindowDetails GetWindow(GetWindowCommand gwCommand) {
|
||||
IntPtr tmphWnd = User32.GetWindow(Handle, gwCommand);
|
||||
if (IntPtr.Zero == tmphWnd) {
|
||||
return null;
|
||||
}
|
||||
WindowDetails windowDetails = new WindowDetails(tmphWnd);
|
||||
windowDetails.parent = this;
|
||||
return windowDetails;
|
||||
|
@ -1389,9 +1392,13 @@ namespace GreenshotPlugin.Core {
|
|||
public static WindowDetails GetActiveWindow() {
|
||||
IntPtr hWnd = User32.GetForegroundWindow();
|
||||
if (hWnd != null && hWnd != IntPtr.Zero) {
|
||||
if (ignoreHandles.Contains(hWnd)) {
|
||||
return WindowDetails.GetDesktopWindow();
|
||||
}
|
||||
|
||||
WindowDetails activeWindow = new WindowDetails(hWnd);
|
||||
// Invisible Windows should not be active
|
||||
if (!activeWindow.Visible || ignoreHandles.Contains(activeWindow.Handle)) {
|
||||
if (!activeWindow.Visible) {
|
||||
return WindowDetails.GetDesktopWindow();
|
||||
}
|
||||
return activeWindow;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue