feat: add icon on windows (#41)

This commit is contained in:
Curve 2021-03-02 14:30:57 +01:00
parent 30a9f8c9d5
commit b3e3318ad5
5 changed files with 10 additions and 1 deletions

View File

@ -10,7 +10,7 @@ file(GLOB src
)
if (WIN32)
add_executable(soundux WIN32 ${src})
add_executable(soundux WIN32 ${src} "assets/icon.rc")
else()
add_executable(soundux ${src})
endif()

1
assets/icon.h Normal file
View File

@ -0,0 +1 @@
#define IDI_ICON1 101

BIN
assets/icon.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

2
assets/icon.rc Normal file
View File

@ -0,0 +1,2 @@
#include "icon.h"
IDI_ICON1 ICON DISCARDABLE "icon.ico"

View File

@ -5,6 +5,7 @@
#include <fancy.hpp>
#if defined(_WIN32)
#include "../assets/icon.h"
int __stdcall WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
#else
int main()
@ -45,6 +46,11 @@ int main()
Soundux::Globals::gGui = std::make_unique<Soundux::Objects::WebView>();
Soundux::Globals::gGui->setup();
#if defined(_WIN32)
HICON hIcon = LoadIcon(GetModuleHandle(nullptr), MAKEINTRESOURCE(IDI_ICON1));
SendMessage(GetActiveWindow(), WM_SETICON, ICON_SMALL, (LPARAM)hIcon);
SendMessage(GetActiveWindow(), WM_SETICON, ICON_BIG, (LPARAM)hIcon);
#endif
Soundux::Globals::gGui->mainLoop();
Soundux::Globals::gAudio.destory();