Added Window.SetIcon

This commit is contained in:
Simon Lübeß
2022-02-14 20:35:35 +01:00
parent 58cf92fb57
commit 574f54e32b
2 changed files with 17 additions and 0 deletions
@@ -250,6 +250,18 @@ namespace GlitchyEngine
[CLink] [CLink]
static extern IntBool IsWindowUnicode(HWND whnd); static extern IntBool IsWindowUnicode(HWND whnd);
public Result<void> SetIcon(StringView filePath)
{
HICON hIcon = LoadImageW(0, filePath.ToScopedNativeWChar!(), .Icon, 0, 0, .LoadFromFile);
if (hIcon == 0)
return .Err;
// WM_SETICON 0x0080
SendMessageW(_windowHandle, 0x0080, 1 /* ICON_BIG */, (int)hIcon);
return .Ok;
}
private static LRESULT MessageHandler(HWND hwnd, uint32 uMsg, WPARAM wParam, LPARAM lParam) private static LRESULT MessageHandler(HWND hwnd, uint32 uMsg, WPARAM wParam, LPARAM lParam)
{ {
void* windowPtr = (void*)GetWindowLongPtrW(hwnd, GWL_USERDATA); void* windowPtr = (void*)GetWindowLongPtrW(hwnd, GWL_USERDATA);
+5
View File
@@ -110,5 +110,10 @@ namespace GlitchyEngine
} }
public extern void Update(); public extern void Update();
/**
* Sets the Icon of the window to the given file.
*/
public extern Result<void> SetIcon(StringView filePath);
} }
} }