mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Icons cleanup
This commit is contained in:
24
app/UI/IconHelper.cs
Normal file
24
app/UI/IconHelper.cs
Normal 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);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user