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

Fixing the defos_set_window_title() #127

Merged
merged 1 commit into from
Jan 31, 2022
Merged
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
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