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();
|
||||
LOG.InfoFormat("Managed to display the message.");
|
||||
return;
|
||||
} catch (Exception) {
|
||||
LOG.WarnFormat("Retrying to show email in {0} seconds... Retries left: {1}", retryInXSeconds, retries);
|
||||
} catch (Exception displayEx) {
|
||||
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.");
|
||||
try {
|
||||
newMail.Save();
|
||||
} catch (Exception saveEx) {
|
||||
LOG.WarnFormat("Saving message to draft failed: {0}", saveEx);
|
||||
}
|
||||
});
|
||||
retryDisplayEmail.Name = "Retry to display email";
|
||||
retryDisplayEmail.IsBackground = true;
|
||||
|
|
|
@ -544,11 +544,7 @@ namespace GreenshotPlugin.Core {
|
|||
return User32.IsIconic(this.hWnd) || Location.X <= -32000;
|
||||
}
|
||||
set {
|
||||
User32.SendMessage(
|
||||
this.hWnd,
|
||||
User32.WM_SYSCOMMAND,
|
||||
(IntPtr)User32.SC_MINIMIZE,
|
||||
IntPtr.Zero);
|
||||
User32.SendMessage(this.hWnd, (int)WindowsMessages.WM_SYSCOMMAND, (IntPtr)User32.SC_MINIMIZE, IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -560,11 +556,7 @@ namespace GreenshotPlugin.Core {
|
|||
return User32.IsZoomed(this.hWnd);
|
||||
}
|
||||
set {
|
||||
User32.SendMessage(
|
||||
this.hWnd,
|
||||
User32.WM_SYSCOMMAND,
|
||||
(IntPtr)User32.SC_MAXIMIZE,
|
||||
IntPtr.Zero);
|
||||
User32.SendMessage(this.hWnd, (int)WindowsMessages.WM_SYSCOMMAND, (IntPtr)User32.SC_MAXIMIZE, IntPtr.Zero);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -700,7 +692,7 @@ namespace GreenshotPlugin.Core {
|
|||
/// </summary>
|
||||
public void Restore() {
|
||||
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.SetForegroundWindow(this.hWnd);
|
||||
|
@ -871,6 +863,9 @@ namespace GreenshotPlugin.Core {
|
|||
tempForm.BackColor = Color.Black;
|
||||
// Make sure everything is visible
|
||||
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();
|
||||
using (Bitmap blackBitmap = WindowCapture.CaptureRectangle(captureRectangle)) {
|
||||
capturedBitmap = ApplyTransparency(blackBitmap, whiteBitmap);
|
||||
|
@ -898,6 +893,9 @@ namespace GreenshotPlugin.Core {
|
|||
}
|
||||
// Make sure everything is visible
|
||||
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();
|
||||
// Capture from the screen
|
||||
capturedBitmap = WindowCapture.CaptureRectangle(captureRectangle);
|
||||
|
|
|
@ -264,9 +264,6 @@ namespace GreenshotPlugin.UnmanagedHelpers {
|
|||
/// User32 Wrappers
|
||||
/// </summary>
|
||||
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_CLOSE = 0xF060;
|
||||
public const int SC_MAXIMIZE = 0xF030;
|
||||
|
@ -410,6 +407,12 @@ namespace GreenshotPlugin.UnmanagedHelpers {
|
|||
[DllImport("user32", SetLastError = true, CharSet = CharSet.Auto)]
|
||||
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: 1 - Count of USER objects
|
||||
/// - Win32 GDI objects (pens, brushes, fonts, palettes, regions, device contexts, bitmap headers)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue