Fix for bug #3579138, minimized windows can't be captured via the context menu.

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2205 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2012-10-26 15:27:48 +00:00
parent 5723f6fa5d
commit 4d41fc0a43
2 changed files with 44 additions and 10 deletions

View file

@ -579,7 +579,8 @@ namespace GreenshotPlugin.Core {
public bool HasParent {
get {
return !IntPtr.Zero.Equals(parentHandle);
GetParent();
return parentHandle != IntPtr.Zero;
}
}
@ -1477,12 +1478,8 @@ namespace GreenshotPlugin.Core {
if (!window.Visible) {
continue;
}
// Ignore internal windows
if (ignoreHandles.Contains(window.Handle)) {
continue;
}
// Ignore some classes
List<string> ignoreClasses = new List<string>(new string[] {"Progman", "XLMAIN", "Button"}); //"MS-SDIa"
List<string> ignoreClasses = new List<string>(new string[] { "Progman", "XLMAIN", "Button", "Dwm" }); //"MS-SDIa"
if (ignoreClasses.Contains(window.ClassName)) {
continue;
}
@ -1497,6 +1494,42 @@ namespace GreenshotPlugin.Core {
return windows;
}
/// <summary>
/// Get all the top level windows
/// </summary>
/// <returns>List<WindowDetails> with all the top level windows</returns>
public static List<WindowDetails> GetTopLevelWindows() {
List<WindowDetails> windows = new List<WindowDetails>();
Rectangle screenBounds = WindowCapture.GetScreenBounds();
List<WindowDetails> allWindows = WindowDetails.GetAllWindows();
foreach (WindowDetails window in allWindows) {
// Ignore windows without title
if (window.Text.Length == 0) {
continue;
}
// Ignore some classes
List<string> ignoreClasses = new List<string>(new string[] { "Progman", "XLMAIN", "Button", "Dwm" }); //"MS-SDIa"
if (ignoreClasses.Contains(window.ClassName)) {
continue;
}
// Windows without size
if (window.WindowRectangle.Size.IsEmpty) {
continue;
}
if (window.HasParent) {
continue;
}
if ((window.ExtendedWindowStyle & ExtendedWindowStyleFlags.WS_EX_TOOLWINDOW) != 0) {
continue;
}
if (!window.Visible && !window.Iconic) {
continue;
}
windows.Add(window);
}
return windows;
}
/// <summary>
/// Find a window belonging to the same process as the supplied window.
/// </summary>