Windows 8: fix for capturing when a fullscreen app is visible, this didn't go away, when having multiple monitors.

git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2456 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
RKrom 2013-02-03 16:26:04 +00:00
parent 7ba6a57b4a
commit 141da5e724
2 changed files with 40 additions and 17 deletions

View file

@ -897,6 +897,13 @@ namespace Greenshot.Helpers {
#region capture with feedback #region capture with feedback
private void CaptureWithFeedback() { private void CaptureWithFeedback() {
using (CaptureForm captureForm = new CaptureForm(capture, windows)) { using (CaptureForm captureForm = new CaptureForm(capture, windows)) {
// Added check for metro (Modern UI) apps, which might be maximized and cover the screen.
// as they don't want to
foreach(WindowDetails app in WindowDetails.GetMetroApps()) {
if (app.Maximised) {
app.HideApp();
}
}
DialogResult result = captureForm.ShowDialog(); DialogResult result = captureForm.ShowDialog();
if (result == DialogResult.OK) { if (result == DialogResult.OK) {
selectedCaptureWindow = captureForm.SelectedCaptureWindow; selectedCaptureWindow = captureForm.SelectedCaptureWindow;

View file

@ -639,18 +639,6 @@ namespace GreenshotPlugin.Core {
/// Gets/Sets whether the window is maximised or not. /// Gets/Sets whether the window is maximised or not.
/// </summary> /// </summary>
public bool Maximised { public bool Maximised {
get {
return User32.IsZoomed(this.hWnd);
}
set {
User32.SendMessage(this.hWnd, (int)WindowsMessages.WM_SYSCOMMAND, (IntPtr)User32.SC_MAXIMIZE, IntPtr.Zero);
}
}
/// <summary>
/// Gets whether the window is visible.
/// </summary>
public bool Visible {
get { get {
if (isApp) { if (isApp) {
Rectangle windowRectangle = WindowRectangle; Rectangle windowRectangle = WindowRectangle;
@ -670,14 +658,42 @@ namespace GreenshotPlugin.Core {
} }
} }
} }
} else {
// Not Fullscreen -> Than it's visible!
return true;
} }
} }
} }
return false; return false;
} }
return User32.IsZoomed(this.hWnd);
}
set {
if (value) {
User32.SendMessage(this.hWnd, (int)WindowsMessages.WM_SYSCOMMAND, (IntPtr)User32.SC_MAXIMIZE, IntPtr.Zero);
} else {
User32.SendMessage(this.hWnd, (int)WindowsMessages.WM_SYSCOMMAND, (IntPtr)User32.SC_MINIMIZE, IntPtr.Zero);
}
}
}
/// <summary>
/// This doesn't work as good as is should, but does move the App out of the way...
/// </summary>
public void HideApp() {
User32.ShowWindow(Handle, ShowWindowCommand.Hide);
}
/// <summary>
/// Gets whether the window is visible.
/// </summary>
public bool Visible {
get {
if (isApp) {
Rectangle windowRectangle = WindowRectangle;
foreach (Screen screen in Screen.AllScreens) {
if (screen.Bounds.Contains(windowRectangle)) {
return true;
}
}
}
if (isAppLauncher) { if (isAppLauncher) {
return IsAppLauncherVisible; return IsAppLauncherVisible;
} }
@ -744,7 +760,7 @@ namespace GreenshotPlugin.Core {
GetWindowRect(out windowRect); GetWindowRect(out windowRect);
} }
if (!HasParent && this.Maximised) { if (!HasParent && (!isApp && Maximised)) {
Size size = Size.Empty; Size size = Size.Empty;
GetBorderSize(out size); GetBorderSize(out size);
windowRect = new Rectangle(windowRect.X + size.Width, windowRect.Y + size.Height, windowRect.Width - (2 * size.Width), windowRect.Height - (2 * size.Height)); windowRect = new Rectangle(windowRect.X + size.Width, windowRect.Y + size.Height, windowRect.Width - (2 * size.Width), windowRect.Height - (2 * size.Height));
@ -1656,7 +1672,7 @@ namespace GreenshotPlugin.Core {
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public static WindowDetails GetAppLauncher() { public static WindowDetails GetAppLauncher() {
IntPtr appLauncher = User32.FindWindow("ImmersiveLauncher", null); IntPtr appLauncher = User32.FindWindow(METRO_APPLAUNCHER_CLASS, null);
if (appLauncher != IntPtr.Zero) { if (appLauncher != IntPtr.Zero) {
return new WindowDetails (appLauncher); return new WindowDetails (appLauncher);
} }