mirror of
https://github.com/jkocon/g-helper.git
synced 2026-02-23 13:00:52 +01:00
Icon Helper
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
using System.Reflection;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace GHelper.UI
|
||||
@@ -16,8 +16,15 @@ namespace GHelper.UI
|
||||
|
||||
public static void SetIcon(Form form, Bitmap icon)
|
||||
{
|
||||
try
|
||||
{
|
||||
SendMessage(form.Handle, WM_SETICON, ICON_BIG, Icon.ExtractAssociatedIcon(Application.ExecutablePath)!.Handle);
|
||||
SendMessage(form.Handle, WM_SETICON, ICON_SMALL, icon.GetHicon());
|
||||
SendMessage(form.Handle, WM_SETICON, ICON_BIG, Icon.ExtractAssociatedIcon(Assembly.GetExecutingAssembly().Location)!.Handle);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.WriteLine($"Error setting icon {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user