Add app icon
This commit is contained in:
1 parent
ff58d90d34
commit
8a77d2ebcb
5 files changed
+23
No files matched your search
@@ -74,6 +74,8 @@ add_executable(msimeui-demo WIN32
|
||||
demos/msimeui-demo/DemoScene.cpp
|
||||
demos/msimeui-demo/DemoScene.h
|
||||
demos/msimeui-demo/main.cpp
|
||||
demos/msimeui-demo/msimeui-demo.rc
|
||||
demos/msimeui-demo/resource.h
|
||||
)
|
||||
|
||||
target_link_libraries(msimeui-demo PRIVATE msimeui)
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 50 KiB |
@@ -0,0 +1,3 @@
|
||||
#include "resource.h"
|
||||
|
||||
IDI_MSIMEUI_ICON ICON "../../assets/msimeui.ico"
|
||||
@@ -0,0 +1,3 @@
|
||||
#pragma once
|
||||
|
||||
#define IDI_MSIMEUI_ICON 101
|
||||
@@ -19,19 +19,34 @@ Window::~Window() = default;
|
||||
|
||||
bool Window::Create()
|
||||
{
|
||||
HICON largeIcon = static_cast<HICON>(
|
||||
LoadImageW(instance_, MAKEINTRESOURCEW(101), IMAGE_ICON, GetSystemMetrics(SM_CXICON), GetSystemMetrics(SM_CYICON), 0));
|
||||
HICON smallIcon = static_cast<HICON>(LoadImageW(instance_, MAKEINTRESOURCEW(101), IMAGE_ICON,
|
||||
GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0));
|
||||
|
||||
WNDCLASSEXW windowClass = {};
|
||||
windowClass.cbSize = sizeof(windowClass);
|
||||
windowClass.lpfnWndProc = WindowProc;
|
||||
windowClass.hInstance = instance_;
|
||||
windowClass.hIcon = largeIcon;
|
||||
windowClass.hCursor = LoadCursor(nullptr, IDC_ARROW);
|
||||
windowClass.hbrBackground = nullptr;
|
||||
windowClass.lpszClassName = className_.c_str();
|
||||
windowClass.hIconSm = smallIcon;
|
||||
RegisterClassExW(&windowClass);
|
||||
|
||||
hwnd_ = CreateWindowExW(0, className_.c_str(), title_.c_str(), WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
|
||||
width_, height_, nullptr, nullptr, instance_, this);
|
||||
if (hwnd_)
|
||||
{
|
||||
if (largeIcon)
|
||||
{
|
||||
SendMessageW(hwnd_, WM_SETICON, ICON_BIG, reinterpret_cast<LPARAM>(largeIcon));
|
||||
}
|
||||
if (smallIcon)
|
||||
{
|
||||
SendMessageW(hwnd_, WM_SETICON, ICON_SMALL, reinterpret_cast<LPARAM>(smallIcon));
|
||||
}
|
||||
SetTimer(hwnd_, 1, GetCaretBlinkTime(), nullptr);
|
||||
}
|
||||
return hwnd_ != nullptr;
|
||||
|
||||
Reference in new issue
Block a user