From a229a7f39fece2ec40308e47684792a9ceb519cd Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 28 Sep 2022 16:57:09 +0200 Subject: [PATCH] Examples: Win32: Always use RegisterClassW() to ensure windows are Unicode. (#5725) --- docs/CHANGELOG.txt | 1 + examples/example_win32_directx10/main.cpp | 10 +++++----- examples/example_win32_directx11/main.cpp | 10 +++++----- examples/example_win32_directx12/main.cpp | 10 +++++----- examples/example_win32_directx9/main.cpp | 10 +++++----- 5 files changed, 21 insertions(+), 20 deletions(-) diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index d08a9ff3..dc4a8db1 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -154,6 +154,7 @@ Other Changes: - Demo: Added more explicit "Center window" mode to "Overlay example". (#5618) - Demo: Fixed Log & Console from losing scrolling position with Auto-Scroll when child is clipped. (#5721) - Examples: Added all SDL examples to default VS solution. +- Examples: Win32: Always use RegisterClassW() to ensure windows are Unicode. (#5725) - Backends: GLFW: Honor GLFW_CURSOR_DISABLED by not setting mouse position. (#5625) [@scorpion-26] - Backends: SDL: Disable SDL 2.0.22 new "auto capture" which prevents drag and drop across windows (e.g. for multi-viewport support) and don't capture mouse when drag and dropping. (#5710) diff --git a/examples/example_win32_directx10/main.cpp b/examples/example_win32_directx10/main.cpp index e0bd4b5c..e2ec2f04 100644 --- a/examples/example_win32_directx10/main.cpp +++ b/examples/example_win32_directx10/main.cpp @@ -26,15 +26,15 @@ int main(int, char**) { // Create application window //ImGui_ImplWin32_EnableDpiAwareness(); - WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, _T("ImGui Example"), NULL }; - ::RegisterClassEx(&wc); - HWND hwnd = ::CreateWindow(wc.lpszClassName, _T("Dear ImGui DirectX10 Example"), WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL); + WNDCLASSEXW wc = { sizeof(wc), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, L"ImGui Example", NULL }; + ::RegisterClassExW(&wc); + HWND hwnd = ::CreateWindowW(wc.lpszClassName, L"Dear ImGui DirectX10 Example", WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL); // Initialize Direct3D if (!CreateDeviceD3D(hwnd)) { CleanupDeviceD3D(); - ::UnregisterClass(wc.lpszClassName, wc.hInstance); + ::UnregisterClassW(wc.lpszClassName, wc.hInstance); return 1; } @@ -154,7 +154,7 @@ int main(int, char**) CleanupDeviceD3D(); ::DestroyWindow(hwnd); - ::UnregisterClass(wc.lpszClassName, wc.hInstance); + ::UnregisterClassW(wc.lpszClassName, wc.hInstance); return 0; } diff --git a/examples/example_win32_directx11/main.cpp b/examples/example_win32_directx11/main.cpp index 4f4a2bd7..d2e31c4f 100644 --- a/examples/example_win32_directx11/main.cpp +++ b/examples/example_win32_directx11/main.cpp @@ -26,15 +26,15 @@ int main(int, char**) { // Create application window //ImGui_ImplWin32_EnableDpiAwareness(); - WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, _T("ImGui Example"), NULL }; - ::RegisterClassEx(&wc); - HWND hwnd = ::CreateWindow(wc.lpszClassName, _T("Dear ImGui DirectX11 Example"), WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL); + WNDCLASSEXW wc = { sizeof(wc), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, L"ImGui Example", NULL }; + ::RegisterClassExW(&wc); + HWND hwnd = ::CreateWindowW(wc.lpszClassName, L"Dear ImGui DirectX11 Example", WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL); // Initialize Direct3D if (!CreateDeviceD3D(hwnd)) { CleanupDeviceD3D(); - ::UnregisterClass(wc.lpszClassName, wc.hInstance); + ::UnregisterClassW(wc.lpszClassName, wc.hInstance); return 1; } @@ -155,7 +155,7 @@ int main(int, char**) CleanupDeviceD3D(); ::DestroyWindow(hwnd); - ::UnregisterClass(wc.lpszClassName, wc.hInstance); + ::UnregisterClassW(wc.lpszClassName, wc.hInstance); return 0; } diff --git a/examples/example_win32_directx12/main.cpp b/examples/example_win32_directx12/main.cpp index 5ad7d41d..4de6246e 100644 --- a/examples/example_win32_directx12/main.cpp +++ b/examples/example_win32_directx12/main.cpp @@ -61,15 +61,15 @@ int main(int, char**) { // Create application window //ImGui_ImplWin32_EnableDpiAwareness(); - WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, _T("ImGui Example"), NULL }; - ::RegisterClassEx(&wc); - HWND hwnd = ::CreateWindow(wc.lpszClassName, _T("Dear ImGui DirectX12 Example"), WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL); + WNDCLASSEXW wc = { sizeof(wc), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, L"ImGui Example", NULL }; + ::RegisterClassExW(&wc); + HWND hwnd = ::CreateWindowW(wc.lpszClassName, L"Dear ImGui DirectX12 Example", WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL); // Initialize Direct3D if (!CreateDeviceD3D(hwnd)) { CleanupDeviceD3D(); - ::UnregisterClass(wc.lpszClassName, wc.hInstance); + ::UnregisterClassW(wc.lpszClassName, wc.hInstance); return 1; } @@ -223,7 +223,7 @@ int main(int, char**) CleanupDeviceD3D(); ::DestroyWindow(hwnd); - ::UnregisterClass(wc.lpszClassName, wc.hInstance); + ::UnregisterClassW(wc.lpszClassName, wc.hInstance); return 0; } diff --git a/examples/example_win32_directx9/main.cpp b/examples/example_win32_directx9/main.cpp index a876cbcb..4c38768f 100644 --- a/examples/example_win32_directx9/main.cpp +++ b/examples/example_win32_directx9/main.cpp @@ -24,15 +24,15 @@ int main(int, char**) { // Create application window //ImGui_ImplWin32_EnableDpiAwareness(); - WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, _T("ImGui Example"), NULL }; - ::RegisterClassEx(&wc); - HWND hwnd = ::CreateWindow(wc.lpszClassName, _T("Dear ImGui DirectX9 Example"), WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL); + WNDCLASSEXW wc = { sizeof(wc), CS_CLASSDC, WndProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, L"ImGui Example", NULL }; + ::RegisterClassExW(&wc); + HWND hwnd = ::CreateWindowW(wc.lpszClassName, L"Dear ImGui DirectX9 Example", WS_OVERLAPPEDWINDOW, 100, 100, 1280, 800, NULL, NULL, wc.hInstance, NULL); // Initialize Direct3D if (!CreateDeviceD3D(hwnd)) { CleanupDeviceD3D(); - ::UnregisterClass(wc.lpszClassName, wc.hInstance); + ::UnregisterClassW(wc.lpszClassName, wc.hInstance); return 1; } @@ -161,7 +161,7 @@ int main(int, char**) CleanupDeviceD3D(); ::DestroyWindow(hwnd); - ::UnregisterClass(wc.lpszClassName, wc.hInstance); + ::UnregisterClassW(wc.lpszClassName, wc.hInstance); return 0; }