Skip to content

Commit

Permalink
Fixing the defos_set_window_title()
Browse files Browse the repository at this point in the history
Changing parameter encoding when window title changes
  • Loading branch information
e1e5en-gd committed Jan 31, 2022
1 parent d0cb233 commit 1159987
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion defos/src/defos_win.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@

#if defined(DM_PLATFORM_WINDOWS) && !defined(DM_HEADLESS)

#define MAX_WINDOW_TITLE_LENGTH 255

#include <dmsdk/sdk.h>
#include "defos_private.h"

#include <atlbase.h>
#include <atlconv.h>
#include <WinUser.h>
#include <Windows.h>
#include <stringapiset.h>

// keep track of window placement when going to/from fullscreen or maximized
static WINDOWPLACEMENT placement = {sizeof(placement)};
Expand Down Expand Up @@ -248,7 +251,13 @@ void defos_set_view_size(float x, float y, float w, float h)

void defos_set_window_title(const char *title_lua)
{
SetWindowTextW(dmGraphics::GetNativeWindowsHWND(), CA2W(title_lua));
wchar_t unicode_title[MAX_WINDOW_TITLE_LENGTH];
int res = MultiByteToWideChar(CP_UTF8, 0, title_lua, -1, unicode_title, MAX_WINDOW_TITLE_LENGTH);
if (res <= 0)
{
unicode_title[0] = 0;
}
SetWindowTextW(dmGraphics::GetNativeWindowsHWND(), unicode_title);
}

void defos_set_window_icon(const char *icon_path)
Expand Down

0 comments on commit 1159987

Please sign in to comment.