Skip to content

Instantly share code, notes, and snippets.

@shiyuugohirao
Last active March 8, 2024 09:47
Show Gist options
  • Save shiyuugohirao/541c9fb6daa76c3407a2c163c8a029f0 to your computer and use it in GitHub Desktop.
Save shiyuugohirao/541c9fb6daa76c3407a2c163c8a029f0 to your computer and use it in GitHub Desktop.
setup icon in openFrameworks app (only windows)
#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