Last active
March 8, 2024 09:47
-
-
Save shiyuugohirao/541c9fb6daa76c3407a2c163c8a029f0 to your computer and use it in GitHub Desktop.
setup icon in openFrameworks app (only windows)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include "ofMain.h" | |
inline void setupIcon(string iconPath) { | |
// set window icon | |
HICON hWindowIcon = NULL; | |
HICON hWindowIconBig = NULL; | |
HWND hwnd = ofGetWin32Window(); | |
if (hWindowIcon != NULL) DestroyIcon(hWindowIcon); | |
if (hWindowIconBig != NULL) DestroyIcon(hWindowIconBig); | |
hWindowIcon = (HICON)LoadImageA(GetModuleHandle(NULL), iconPath.c_str(), IMAGE_ICON, 16, 16, LR_LOADFROMFILE); | |
hWindowIconBig = (HICON)LoadImageA(GetModuleHandle(NULL), iconPath.c_str(), IMAGE_ICON, 32, 32, LR_LOADFROMFILE); | |
SendMessage(hwnd, WM_SETICON, ICON_SMALL, (LPARAM)hWindowIcon); | |
SendMessage(hwnd, WM_SETICON, ICON_BIG, (LPARAM)hWindowIconBig); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment