Icons cleanup

This commit is contained in:
Serge
2023-11-21 13:07:03 +01:00
parent 45e7e5551e
commit 267cf6387f
10 changed files with 39 additions and 40 deletions

24
app/UI/IconHelper.cs Normal file
View File

@@ -0,0 +1,24 @@
using System.Reflection;
using System.Runtime.InteropServices;
namespace GHelper.UI
{
public class IconHelper
{
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern IntPtr SendMessage(IntPtr hWnd, uint Msg, IntPtr wParam, IntPtr lParam);
private const uint WM_SETICON = 0x80u;
private const int ICON_SMALL = 0;
private const int ICON_BIG = 1;
public static void SetIcon(Form form, Bitmap icon)
{
SendMessage(form.Handle, WM_SETICON, ICON_SMALL, icon.GetHicon());
SendMessage(form.Handle, WM_SETICON, ICON_BIG, Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location)!.Handle);
}
}
}