Skip to content

Commit

Permalink
Windows standalone: Define UNICODE and avoid some unnecessary convers…
Browse files Browse the repository at this point in the history
…ions. Don't leak NOMINMAX
  • Loading branch information
mthierman committed Sep 21, 2024
1 parent 2b1120f commit 9b69fa4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion cmake/wrap_standalone.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@ function(target_add_standalone_wrapper)
CLAP_WRAPPER_HAS_WIN32
)

target_compile_definitions(${salib} PUBLIC
target_compile_definitions(${SA_TARGET} PRIVATE
UNICODE
NOMINMAX
)

Expand Down
12 changes: 6 additions & 6 deletions src/detail/standalone/windows/windows_standalone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ ::HBRUSH getBrushFromSystem(int name)
return static_cast<::HBRUSH>(::GetStockObject(name));
}

::HCURSOR getCursorFromSystem(::LPCSTR name)
::HCURSOR getCursorFromSystem(::LPCWSTR name)
{
return static_cast<::HCURSOR>(
::LoadImageA(nullptr, name, IMAGE_CURSOR, 0, 0, LR_SHARED | LR_DEFAULTSIZE));
::LoadImageW(nullptr, name, IMAGE_CURSOR, 0, 0, LR_SHARED | LR_DEFAULTSIZE));
}

::HICON getIconFromSystem(::LPCSTR name)
::HICON getIconFromSystem(::LPCWSTR name)
{
return static_cast<::HICON>(::LoadImageA(nullptr, name, IMAGE_ICON, 0, 0, LR_SHARED | LR_DEFAULTSIZE));
return static_cast<::HICON>(::LoadImageW(nullptr, name, IMAGE_ICON, 0, 0, LR_SHARED | LR_DEFAULTSIZE));
}

::HICON getIconFromResource()
Expand Down Expand Up @@ -433,7 +433,7 @@ void Control::refreshFont(double scale)

void ComboBox::create(const std::string& name, uintptr_t id, ::HWND parentHwnd)
{
hwnd.reset(::CreateWindowExW(0, toUTF16(WC_COMBOBOX).c_str(), toUTF16(name).c_str(),
hwnd.reset(::CreateWindowExW(0, WC_COMBOBOXW, toUTF16(name).c_str(),
WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST, 0, 0, 0, 0, parentHwnd,
(::HMENU)id, getInstance(), nullptr));

Expand Down Expand Up @@ -494,7 +494,7 @@ ::LRESULT CALLBACK ComboBox::procedure(::HWND hwnd, ::UINT msg, ::WPARAM wparam,

void ListBox::create(const std::string& name, uintptr_t id, ::HWND parentHwnd)
{
hwnd.reset(::CreateWindowExW(0, toUTF16(WC_LISTBOX).c_str(), toUTF16(name).c_str(),
hwnd.reset(::CreateWindowExW(0, WC_LISTBOXW, toUTF16(name).c_str(),
WS_CHILD | WS_VISIBLE | LBS_MULTIPLESEL | LBS_NOTIFY, 0, 0, 0, 0,
parentHwnd, (::HMENU)id, getInstance(), nullptr));

Expand Down
4 changes: 2 additions & 2 deletions src/detail/standalone/windows/windows_standalone.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ ::HMODULE getInstance();
::HFONT getFontFromSystem(int name = DEFAULT_GUI_FONT);
::HFONT getScaledFontFromSystem(double scale);
::HBRUSH getBrushFromSystem(int name = BLACK_BRUSH);
::HCURSOR getCursorFromSystem(::LPCSTR name = IDC_ARROW);
::HICON getIconFromSystem(::LPCSTR name = IDI_APPLICATION);
::HCURSOR getCursorFromSystem(::LPCWSTR name = IDC_ARROW);
::HICON getIconFromSystem(::LPCWSTR name = IDI_APPLICATION);
::HICON getIconFromResource();
::HMENU getSystemMenu(::HWND hwnd);

Expand Down

0 comments on commit 9b69fa4

Please sign in to comment.