mirror of
https://github.com/greenshot/greenshot
synced 2025-08-13 18:27:03 -07:00
Fixes: Catching an outlook exception that can be ignored. Making sure that the window to be captured is active, so the colors are right. Also a little cleanup, and added FindWindow to the User32.cs so we can use this to find Metro (Modern UI) applications, this still needs to be added to the WindowsHelper.cs
git-svn-id: http://svn.code.sf.net/p/greenshot/code/trunk@2244 7dccd23d-a4a3-4e1f-8c07-b4c1b4018ab4
This commit is contained in:
parent
599bb594ad
commit
15d5bb58e4
3 changed files with 23 additions and 18 deletions
|
@ -375,12 +375,16 @@ namespace Greenshot.Interop.Office {
|
||||||
newMail.GetInspector().Activate();
|
newMail.GetInspector().Activate();
|
||||||
LOG.InfoFormat("Managed to display the message.");
|
LOG.InfoFormat("Managed to display the message.");
|
||||||
return;
|
return;
|
||||||
} catch (Exception) {
|
} catch (Exception displayEx) {
|
||||||
LOG.WarnFormat("Retrying to show email in {0} seconds... Retries left: {1}", retryInXSeconds, retries);
|
LOG.WarnFormat("Error displaying message: {0}, retrying to show email in {1} seconds... Retries left: {2}", displayEx, retryInXSeconds, retries);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LOG.WarnFormat("Retry failed, saving message to draft.");
|
LOG.WarnFormat("Retry failed, saving message to draft.");
|
||||||
newMail.Save();
|
try {
|
||||||
|
newMail.Save();
|
||||||
|
} catch (Exception saveEx) {
|
||||||
|
LOG.WarnFormat("Saving message to draft failed: {0}", saveEx);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
retryDisplayEmail.Name = "Retry to display email";
|
retryDisplayEmail.Name = "Retry to display email";
|
||||||
retryDisplayEmail.IsBackground = true;
|
retryDisplayEmail.IsBackground = true;
|
||||||
|
|
|
@ -544,11 +544,7 @@ namespace GreenshotPlugin.Core {
|
||||||
return User32.IsIconic(this.hWnd) || Location.X <= -32000;
|
return User32.IsIconic(this.hWnd) || Location.X <= -32000;
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
User32.SendMessage(
|
User32.SendMessage(this.hWnd, (int)WindowsMessages.WM_SYSCOMMAND, (IntPtr)User32.SC_MINIMIZE, IntPtr.Zero);
|
||||||
this.hWnd,
|
|
||||||
User32.WM_SYSCOMMAND,
|
|
||||||
(IntPtr)User32.SC_MINIMIZE,
|
|
||||||
IntPtr.Zero);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -560,11 +556,7 @@ namespace GreenshotPlugin.Core {
|
||||||
return User32.IsZoomed(this.hWnd);
|
return User32.IsZoomed(this.hWnd);
|
||||||
}
|
}
|
||||||
set {
|
set {
|
||||||
User32.SendMessage(
|
User32.SendMessage(this.hWnd, (int)WindowsMessages.WM_SYSCOMMAND, (IntPtr)User32.SC_MAXIMIZE, IntPtr.Zero);
|
||||||
this.hWnd,
|
|
||||||
User32.WM_SYSCOMMAND,
|
|
||||||
(IntPtr)User32.SC_MAXIMIZE,
|
|
||||||
IntPtr.Zero);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -700,7 +692,7 @@ namespace GreenshotPlugin.Core {
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void Restore() {
|
public void Restore() {
|
||||||
if (Iconic) {
|
if (Iconic) {
|
||||||
User32.SendMessage(this.hWnd, User32.WM_SYSCOMMAND, (IntPtr)User32.SC_RESTORE, IntPtr.Zero);
|
User32.SendMessage(this.hWnd, (int)WindowsMessages.WM_SYSCOMMAND, (IntPtr)User32.SC_RESTORE, IntPtr.Zero);
|
||||||
}
|
}
|
||||||
User32.BringWindowToTop(this.hWnd);
|
User32.BringWindowToTop(this.hWnd);
|
||||||
User32.SetForegroundWindow(this.hWnd);
|
User32.SetForegroundWindow(this.hWnd);
|
||||||
|
@ -871,6 +863,9 @@ namespace GreenshotPlugin.Core {
|
||||||
tempForm.BackColor = Color.Black;
|
tempForm.BackColor = Color.Black;
|
||||||
// Make sure everything is visible
|
// Make sure everything is visible
|
||||||
tempForm.Refresh();
|
tempForm.Refresh();
|
||||||
|
// Make sure the application window is active, so the colors & buttons are right
|
||||||
|
ToForeground();
|
||||||
|
// Make sure all changes are processed and visisble
|
||||||
Application.DoEvents();
|
Application.DoEvents();
|
||||||
using (Bitmap blackBitmap = WindowCapture.CaptureRectangle(captureRectangle)) {
|
using (Bitmap blackBitmap = WindowCapture.CaptureRectangle(captureRectangle)) {
|
||||||
capturedBitmap = ApplyTransparency(blackBitmap, whiteBitmap);
|
capturedBitmap = ApplyTransparency(blackBitmap, whiteBitmap);
|
||||||
|
@ -898,6 +893,9 @@ namespace GreenshotPlugin.Core {
|
||||||
}
|
}
|
||||||
// Make sure everything is visible
|
// Make sure everything is visible
|
||||||
tempForm.Refresh();
|
tempForm.Refresh();
|
||||||
|
// Make sure the application window is active, so the colors & buttons are right
|
||||||
|
ToForeground();
|
||||||
|
// Make sure all changes are processed and visisble
|
||||||
Application.DoEvents();
|
Application.DoEvents();
|
||||||
// Capture from the screen
|
// Capture from the screen
|
||||||
capturedBitmap = WindowCapture.CaptureRectangle(captureRectangle);
|
capturedBitmap = WindowCapture.CaptureRectangle(captureRectangle);
|
||||||
|
|
|
@ -264,9 +264,6 @@ namespace GreenshotPlugin.UnmanagedHelpers {
|
||||||
/// User32 Wrappers
|
/// User32 Wrappers
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class User32 {
|
public class User32 {
|
||||||
public const int WM_COMMAND = 0x111;
|
|
||||||
public const int WM_SYSCOMMAND = 0x112;
|
|
||||||
|
|
||||||
public const int SC_RESTORE = 0xF120;
|
public const int SC_RESTORE = 0xF120;
|
||||||
public const int SC_CLOSE = 0xF060;
|
public const int SC_CLOSE = 0xF060;
|
||||||
public const int SC_MAXIMIZE = 0xF030;
|
public const int SC_MAXIMIZE = 0xF030;
|
||||||
|
@ -409,7 +406,13 @@ namespace GreenshotPlugin.UnmanagedHelpers {
|
||||||
public static extern IntPtr SetClipboardViewer(IntPtr hWndNewViewer);
|
public static extern IntPtr SetClipboardViewer(IntPtr hWndNewViewer);
|
||||||
[DllImport("user32", SetLastError = true, CharSet = CharSet.Auto)]
|
[DllImport("user32", SetLastError = true, CharSet = CharSet.Auto)]
|
||||||
public static extern bool ChangeClipboardChain(IntPtr hWndRemove, IntPtr hWndNewNext);
|
public static extern bool ChangeClipboardChain(IntPtr hWndRemove, IntPtr hWndNewNext);
|
||||||
|
|
||||||
|
// Added for finding Metro apps
|
||||||
|
[DllImport("user32", SetLastError = true)]
|
||||||
|
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);
|
||||||
|
[DllImport("user32", SetLastError = true)]
|
||||||
|
public static extern IntPtr FindWindowEx(IntPtr hwndParent, IntPtr hwndChildAfter, string lpszClass, string lpszWindow);
|
||||||
|
|
||||||
/// uiFlags: 0 - Count of GDI objects
|
/// uiFlags: 0 - Count of GDI objects
|
||||||
/// uiFlags: 1 - Count of USER objects
|
/// uiFlags: 1 - Count of USER objects
|
||||||
/// - Win32 GDI objects (pens, brushes, fonts, palettes, regions, device contexts, bitmap headers)
|
/// - Win32 GDI objects (pens, brushes, fonts, palettes, regions, device contexts, bitmap headers)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue