From 06c3ae693596be8fcba6c8cbf12339ce3a1dfd61 Mon Sep 17 00:00:00 2001 From: kirill-jjj Date: Thu, 22 Jan 2026 19:54:14 +0500 Subject: [PATCH 1/3] fix: cast control ids to HMENU safely --- gui.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/gui.cpp b/gui.cpp index 760c2b4..cfbee5d 100644 --- a/gui.cpp +++ b/gui.cpp @@ -418,7 +418,7 @@ namespace gui { width, height, hwndParent, - (HMENU)id, + reinterpret_cast(static_cast(id)), NULL, NULL ); @@ -435,7 +435,7 @@ namespace gui { width, height, hwndParent, - (HMENU)id, + reinterpret_cast(static_cast(id)), NULL, NULL ); @@ -452,7 +452,7 @@ namespace gui { width, height, hwndParent, - (HMENU)id, + reinterpret_cast(static_cast(id)), NULL, NULL ); @@ -476,7 +476,7 @@ namespace gui { width, height, hwndParent, - (HMENU)id, + reinterpret_cast(static_cast(id)), NULL, NULL ); @@ -496,7 +496,7 @@ namespace gui { width, height, hwndParent, - (HMENU)id, + reinterpret_cast(static_cast(id)), NULL, NULL ); @@ -615,4 +615,4 @@ namespace gui { { SetWindowText(hwndEdit, lpszText); } -} \ No newline at end of file +} From d66fa59dcf2c0b4c7a17371b4ffaa936485f8b50 Mon Sep 17 00:00:00 2001 From: kirill-jjj Date: Thu, 22 Jan 2026 19:54:33 +0500 Subject: [PATCH 2/3] fix: clamp timer and cast listbox results --- gui.cpp | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/gui.cpp b/gui.cpp index cfbee5d..1e3694b 100644 --- a/gui.cpp +++ b/gui.cpp @@ -5,6 +5,7 @@ #include #include #include +#include #include namespace gui { @@ -345,7 +346,18 @@ namespace gui { } else { - return std::chrono::duration_cast(std::chrono::steady_clock::now() - initTime).count(); + const auto elapsed_ms = std::chrono::duration_cast( + std::chrono::steady_clock::now() - initTime + ).count(); + if (elapsed_ms > std::numeric_limits::max()) + { + return std::numeric_limits::max(); + } + if (elapsed_ms < std::numeric_limits::min()) + { + return std::numeric_limits::min(); + } + return static_cast(elapsed_ms); } } @@ -514,7 +526,7 @@ namespace gui { void delete_list_selections(HWND hwndList) { - int count = SendMessage(hwndList, LB_GETSELCOUNT, 0, 0); + const int count = static_cast(SendMessage(hwndList, LB_GETSELCOUNT, 0, 0)); if (count > 0) { std::vector selections(count); @@ -550,15 +562,15 @@ namespace gui { int get_list_position(HWND hwndList) { - return SendMessage(hwndList, LB_GETCURSEL, 0, 0); + return static_cast(SendMessage(hwndList, LB_GETCURSEL, 0, 0)); } std::wstring get_focused_list_item_name(HWND hwndList) { - int focusedIndex = SendMessage(hwndList, LB_GETCURSEL, 0, 0); + const int focusedIndex = static_cast(SendMessage(hwndList, LB_GETCURSEL, 0, 0)); if (focusedIndex != LB_ERR) { - int textLength = SendMessage(hwndList, LB_GETTEXTLEN, focusedIndex, 0); + const int textLength = static_cast(SendMessage(hwndList, LB_GETTEXTLEN, focusedIndex, 0)); if (textLength != LB_ERR) { std::wstring listItemText; From 9e5e1f4a16ab44c3c3e115043127b4e763cd9272 Mon Sep 17 00:00:00 2001 From: kirill-jjj Date: Thu, 22 Jan 2026 19:57:25 +0500 Subject: [PATCH 3/3] fix: avoid min/max macro clashes --- gui.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gui.cpp b/gui.cpp index 1e3694b..4b50ac7 100644 --- a/gui.cpp +++ b/gui.cpp @@ -349,13 +349,13 @@ namespace gui { const auto elapsed_ms = std::chrono::duration_cast( std::chrono::steady_clock::now() - initTime ).count(); - if (elapsed_ms > std::numeric_limits::max()) + if (elapsed_ms > (std::numeric_limits::max)()) { - return std::numeric_limits::max(); + return (std::numeric_limits::max)(); } - if (elapsed_ms < std::numeric_limits::min()) + if (elapsed_ms < (std::numeric_limits::min)()) { - return std::numeric_limits::min(); + return (std::numeric_limits::min)(); } return static_cast(elapsed_ms); }