mirror of
https://github.com/ShareX/ShareX.git
synced 2024-06-29 03:30:43 +12:00
Get window icon async
This commit is contained in:
parent
16c1965856
commit
3cdf839f01
|
@ -147,7 +147,9 @@ public static IntPtr SetWindowLong(IntPtr hWnd, int nIndex, IntPtr dwNewLong)
|
|||
|
||||
private static Icon GetSmallApplicationIcon(IntPtr handle)
|
||||
{
|
||||
SendMessageTimeout(handle, (int)WindowsMessages.GETICON, NativeConstants.ICON_SMALL2, 0, SendMessageTimeoutFlags.SMTO_ABORTIFHUNG, 1000, out IntPtr iconHandle);
|
||||
IntPtr iconHandle;
|
||||
|
||||
SendMessageTimeout(handle, (int)WindowsMessages.GETICON, NativeConstants.ICON_SMALL2, 0, SendMessageTimeoutFlags.SMTO_ABORTIFHUNG, 1000, out iconHandle);
|
||||
|
||||
if (iconHandle == IntPtr.Zero)
|
||||
{
|
||||
|
|
|
@ -1197,16 +1197,15 @@ private async Task PrepareCaptureMenuAsync(ToolStripMenuItem tsmiWindow, EventHa
|
|||
ToolStripMenuItem tsmi = new ToolStripMenuItem(title);
|
||||
tsmi.Tag = window;
|
||||
tsmi.Click += handlerWindow;
|
||||
items.Add(tsmi);
|
||||
|
||||
using (Icon icon = window.Icon)
|
||||
using (Icon icon = await Task.Run(() => window.Icon))
|
||||
{
|
||||
if (icon != null && icon.Width > 0 && icon.Height > 0)
|
||||
{
|
||||
tsmi.Image = icon.ToBitmap();
|
||||
}
|
||||
}
|
||||
|
||||
items.Add(tsmi);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue