diff options
-rw-r--r-- | src/win.c | 53 | ||||
-rw-r--r-- | src/win_gl.c | 2 | ||||
-rw-r--r-- | src/win_vulkan.c | 2 |
3 files changed, 37 insertions, 20 deletions
@@ -94,6 +94,12 @@ puglWinStatus(const BOOL success) static bool puglRegisterWindowClass(const char* name) { +#ifdef UNICODE + wchar_t* const wname = puglUtf8ToWideChar(name); +#else + const char* const wname = name; +#endif + HMODULE module = NULL; if (!GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, @@ -103,7 +109,7 @@ puglRegisterWindowClass(const char* name) } WNDCLASSEX wc = PUGL_INIT_STRUCT; - if (GetClassInfoEx(module, name, &wc)) { + if (GetClassInfoEx(module, wname, &wc)) { return true; // Already registered } @@ -114,9 +120,13 @@ puglRegisterWindowClass(const char* name) wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH); - wc.lpszClassName = name; + wc.lpszClassName = wname; - return !!RegisterClassEx(&wc); + const bool success = !!RegisterClassEx(&wc); +#ifdef UNICODE + free(wname); +#endif + return success; } static unsigned @@ -174,7 +184,7 @@ static double puglWinGetViewScaleFactor(const PuglView* const view) { const HMODULE shcore = - LoadLibraryEx("Shcore.dll", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32); + LoadLibraryExA("Shcore.dll", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32); if (!shcore) { return 1.0; } @@ -209,7 +219,7 @@ puglInitWorldInternals(PuglWorldType type, PuglWorldFlags PUGL_UNUSED(flags)) if (type == PUGL_PROGRAM) { HMODULE user32 = - LoadLibraryEx("user32.dll", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32); + LoadLibraryExA("user32.dll", NULL, LOAD_LIBRARY_SEARCH_SYSTEM32); if (user32) { PFN_SetProcessDPIAware SetProcessDPIAware = (PFN_SetProcessDPIAware)GetProcAddress(user32, "SetProcessDPIAware"); @@ -398,7 +408,14 @@ puglFreeViewInternals(PuglView* view) void puglFreeWorldInternals(PuglWorld* world) { +#ifdef UNICODE + wchar_t* const wname = puglUtf8ToWideChar(world->strings[PUGL_CLASS_NAME]); + UnregisterClass(wname, NULL); + free(wname); +#else UnregisterClass(world->strings[PUGL_CLASS_NAME], NULL); +#endif + free(world->impl); } @@ -1481,7 +1498,7 @@ puglPaste(PuglView* const view) return PUGL_SUCCESS; } -static const char* const cursor_ids[] = { +static const TCHAR* const cursor_ids[] = { IDC_ARROW, // ARROW IDC_IBEAM, // CARET IDC_CROSS, // CROSSHAIR @@ -1606,18 +1623,18 @@ puglWinCreateWindow(PuglView* const view, AdjustWindowRectEx(&wr, winFlags, FALSE, winExFlags); // Create window and get drawing context - if (!(*hwnd = CreateWindowEx(winExFlags, - className, - title, - winFlags, - wr.left, - wr.right, - wr.right - wr.left, - wr.bottom - wr.top, - (HWND)parent, - NULL, - NULL, - NULL))) { + if (!(*hwnd = CreateWindowExA(winExFlags, + className, + title, + winFlags, + wr.left, + wr.right, + wr.right - wr.left, + wr.bottom - wr.top, + (HWND)parent, + NULL, + NULL, + NULL))) { return PUGL_REALIZE_FAILED; } diff --git a/src/win_gl.c b/src/win_gl.c index f707fc6..01321d4 100644 --- a/src/win_gl.c +++ b/src/win_gl.c @@ -288,7 +288,7 @@ puglGetProcAddress(const char* name) return func ? func - : (PuglGlFunc)GetProcAddress(GetModuleHandle("opengl32.dll"), name); + : (PuglGlFunc)GetProcAddress(GetModuleHandleA("opengl32.dll"), name); } PuglStatus diff --git a/src/win_vulkan.c b/src/win_vulkan.c index 6d7c632..2927447 100644 --- a/src/win_vulkan.c +++ b/src/win_vulkan.c @@ -32,7 +32,7 @@ puglNewVulkanLoader(PuglWorld* PUGL_UNUSED(world), const char* const filename = libraryName ? libraryName : "vulkan-1.dll"; if (!(loader->libvulkan = - LoadLibraryEx(filename, NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS))) { + LoadLibraryExA(filename, NULL, LOAD_LIBRARY_SEARCH_DEFAULT_DIRS))) { free(loader); return NULL; } |