Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows standalone: Define UNICODE and avoid some unnecessary convers… #310

Merged
merged 1 commit into from
Sep 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading