From 84c3a7e52535d981a2847d51f4a35d7b8a16c6fd Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sun, 4 Aug 2024 07:59:30 +0200 Subject: [PATCH] Support wide window titles --- src/html_ui.cpp | 5 +++++ src/html_window.cpp | 10 ++++++++++ src/html_window.hpp | 3 +++ src/window.cpp | 10 +++++++++- src/window.hpp | 4 ++++ 5 files changed, 31 insertions(+), 1 deletion(-) diff --git a/src/html_ui.cpp b/src/html_ui.cpp index df8dd2a..6e286d5 100644 --- a/src/html_ui.cpp +++ b/src/html_ui.cpp @@ -9,6 +9,11 @@ namespace momo { } + html_ui::html_ui(const std::wstring& title, const size_t width, const size_t height) + : window_(std::make_unique(title, static_cast(width), static_cast(height))) + { + } + html_ui::~html_ui() = default; html_ui::html_ui(html_ui&&) noexcept = default; html_ui& html_ui::operator=(html_ui&&) noexcept = default; diff --git a/src/html_window.cpp b/src/html_window.cpp index f40f325..6091c9a 100644 --- a/src/html_window.cpp +++ b/src/html_window.cpp @@ -12,6 +12,16 @@ namespace momo { } + html_window::html_window(const std::wstring& title, const int width, const int height, const long flags) + : window_(title, width, height, + [this](window*, const UINT message, const WPARAM w_param, + const LPARAM l_param) -> std::optional + { + return this->processor(message, w_param, l_param); + }, flags) + { + } + window& html_window::get_window() { return this->window_; diff --git a/src/html_window.hpp b/src/html_window.hpp index c5f4121..368445d 100644 --- a/src/html_window.hpp +++ b/src/html_window.hpp @@ -11,6 +11,9 @@ namespace momo html_window(const std::string& title, int width, int height, long flags = (WS_OVERLAPPEDWINDOW & ~(WS_THICKFRAME | WS_MAXIMIZEBOX))); + html_window(const std::wstring& title, int width, int height, + long flags = (WS_OVERLAPPEDWINDOW & ~(WS_THICKFRAME | WS_MAXIMIZEBOX))); + ~html_window() = default; window& get_window(); diff --git a/src/window.cpp b/src/window.cpp index 3b6bae7..c83ad67 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -41,6 +41,14 @@ namespace momo } window::window(const std::string& title, const int width, const int height, + std::function(window*, UINT, WPARAM, LPARAM)> callback, + const long flags) + : window(convert_utf8_to_wide(title), width, height,std::move(callback), flags) + { + + } + + window::window(const std::wstring& title, const int width, const int height, std::function(window*, UINT, WPARAM, LPARAM)> callback, const long flags) : callback_(std::move(callback)) @@ -65,7 +73,7 @@ namespace momo ++window_count; - this->handle_ = CreateWindowExW(NULL, this->wc_.lpszClassName, convert_utf8_to_wide(title).data(), flags, x, y, + this->handle_ = CreateWindowExW(NULL, this->wc_.lpszClassName, title.data(), flags, x, y, width, height, nullptr, nullptr, this->wc_.hInstance, this); constexpr BOOL value = TRUE; diff --git a/src/window.hpp b/src/window.hpp index a56732d..9a2c32b 100644 --- a/src/window.hpp +++ b/src/window.hpp @@ -15,6 +15,10 @@ namespace momo std::function(window*, UINT, WPARAM, LPARAM)> callback, long flags = (WS_OVERLAPPEDWINDOW & ~(WS_THICKFRAME | WS_MAXIMIZEBOX))); + window(const std::wstring& title, int width, int height, + std::function(window*, UINT, WPARAM, LPARAM)> callback, + long flags = (WS_OVERLAPPEDWINDOW & ~(WS_THICKFRAME | WS_MAXIMIZEBOX))); + virtual ~window(); void close();