windows icon sizing and WNDCLASSEX for small icon
continuous-integration/drone/pr Build is passing Details

This commit is contained in:
Dan Ballard 2021-06-03 14:34:21 -07:00
parent c6c9899a78
commit dbdb62b8e2
10 changed files with 54 additions and 5 deletions

View File

@ -52,7 +52,16 @@ END
// Icon with lowest ID value placed first to ensure application icon // Icon with lowest ID value placed first to ensure application icon
// remains consistent on all systems. // remains consistent on all systems.
IDI_APP_ICON ICON "resources\\app_icon.ico" IDI_APP_ICON_LG ICON "resources\\knot_256.ico"
IDI_APP_ICON_SM ICON "resources\\knot_64.ico"
IDI_APP_ICON_256 ICON "resources\\knot_256.ico"
IDI_APP_ICON_128 ICON "resources\\knot_128.ico"
IDI_APP_ICON_64 ICON "resources\\knot_64.ico"
IDI_APP_ICON_48 ICON "resources\\knot_48.ico"
IDI_APP_ICON_32 ICON "resources\\knot_32.ico"
IDI_APP_ICON_16 ICON "resources\\knot_16.ico"
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////

View File

@ -2,7 +2,16 @@
// Microsoft Visual C++ generated include file. // Microsoft Visual C++ generated include file.
// Used by Runner.rc // Used by Runner.rc
// //
#define IDI_APP_ICON 101 #define IDI_APP_ICON_LG 101
#define IDI_APP_ICON_SM 102
#define IDI_APP_ICON_256 103
#define IDI_APP_ICON_128 104
#define IDI_APP_ICON_64 105
#define IDI_APP_ICON_48 106
#define IDI_APP_ICON_32 107
#define IDI_APP_ICON_16 108
// Next default values for new objects // Next default values for new objects
// //

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@ -1,4 +1,5 @@
#include "win32_window.h" #include "win32_window.h"
#include "winuser.h"
#include <flutter_windows.h> #include <flutter_windows.h>
@ -70,19 +71,49 @@ WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr;
const wchar_t* WindowClassRegistrar::GetWindowClass() { const wchar_t* WindowClassRegistrar::GetWindowClass() {
if (!class_registered_) { if (!class_registered_) {
WNDCLASS window_class{}; WNDCLASSEX window_class{};
window_class.cbSize = sizeof(WNDCLASSEX);
window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); window_class.hCursor = LoadCursor(nullptr, IDC_ARROW);
window_class.lpszClassName = kWindowClassName; window_class.lpszClassName = kWindowClassName;
window_class.style = CS_HREDRAW | CS_VREDRAW; window_class.style = CS_HREDRAW | CS_VREDRAW;
window_class.cbClsExtra = 0; window_class.cbClsExtra = 0;
window_class.cbWndExtra = 0; window_class.cbWndExtra = 0;
window_class.hInstance = GetModuleHandle(nullptr); window_class.hInstance = GetModuleHandle(nullptr);
int icon_sz = GetSystemMetrics(SM_CXICON);
int iconh_id = IDI_APP_ICON_32;
if (icon_sz > 128) {
iconh_id = IDI_APP_ICON_256;
} else if (icon_sz > 64) {
iconh_id = IDI_APP_ICON_128;
} else if (icon_sz > 48) {
iconh_id = IDI_APP_ICON_64;
} else if (icon_sz > 32) {
iconh_id = IDI_APP_ICON_48;
}
window_class.hIcon = window_class.hIcon =
LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); LoadIcon(window_class.hInstance, MAKEINTRESOURCE(iconh_id));
int icon_sm_sz = GetSystemMetrics(SM_CXSMICON);
int iconsmh_id = IDI_APP_ICON_16;
if (icon_sm_sz > 128) {
iconsmh_id = IDI_APP_ICON_256;
} else if (icon_sm_sz > 64) {
iconsmh_id = IDI_APP_ICON_128;
} else if (icon_sm_sz > 48) {
iconsmh_id = IDI_APP_ICON_64;
} else if (icon_sm_sz > 32) {
iconsmh_id = IDI_APP_ICON_48;
} else if (icon_sm_sz > 16) {
iconsmh_id = IDI_APP_ICON_32;
}
window_class.hIconSm =
LoadIcon(window_class.hInstance, MAKEINTRESOURCE(iconsmh_id));
window_class.hbrBackground = 0; window_class.hbrBackground = 0;
window_class.lpszMenuName = nullptr; window_class.lpszMenuName = nullptr;
window_class.lpfnWndProc = Win32Window::WndProc; window_class.lpfnWndProc = Win32Window::WndProc;
RegisterClass(&window_class); RegisterClassEx(&window_class);
class_registered_ = true; class_registered_ = true;
} }
return kWindowClassName; return kWindowClassName;