mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 13:49:53 -06:00
Kill off some usages of c_str.
Also changes some function params, but this is ok. Some simplifications were also able to be made (ie. killing off strcmps with ==, etc).
This commit is contained in:
@ -2,6 +2,7 @@
|
||||
// Licensed under GPLv2
|
||||
// Refer to the license.txt file included.
|
||||
|
||||
#include <string>
|
||||
#include <windows.h>
|
||||
|
||||
#include "Core/ConfigManager.h"
|
||||
@ -22,8 +23,6 @@ WNDCLASSEX wndClass;
|
||||
const TCHAR m_szClassName[] = _T("DolphinEmuWnd");
|
||||
int g_winstyle;
|
||||
static volatile bool s_sizing;
|
||||
static const int TITLE_TEXT_BUF_SIZE = 1024;
|
||||
TCHAR m_titleTextBuffer[TITLE_TEXT_BUF_SIZE];
|
||||
static const int WM_SETTEXT_CUSTOM = WM_USER + WM_SETTEXT;
|
||||
|
||||
bool IsSizing()
|
||||
@ -193,27 +192,11 @@ void SetSize(int width, int height)
|
||||
MoveWindow(m_hWnd, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top, TRUE);
|
||||
}
|
||||
|
||||
void SetWindowText(const TCHAR* text)
|
||||
void SetWindowText(const std::string& text)
|
||||
{
|
||||
// the simple way.
|
||||
// we don't do this because it's a blocking call and the GUI thread might be waiting for us.
|
||||
//::SetWindowText(m_hWnd, text);
|
||||
|
||||
// copy to m_titleTextBuffer in such a way that
|
||||
// it remains null-terminated and without garbage data at every point in time,
|
||||
// in case another thread reads it while we're doing this.
|
||||
for (int i = 0; i < TITLE_TEXT_BUF_SIZE-1; ++i)
|
||||
{
|
||||
m_titleTextBuffer[i+1] = 0;
|
||||
TCHAR c = text[i];
|
||||
m_titleTextBuffer[i] = c;
|
||||
if (!c)
|
||||
break;
|
||||
}
|
||||
|
||||
// the OS doesn't allow posting WM_SETTEXT,
|
||||
// so we post our own message and convert it to that in WndProc
|
||||
PostMessage(m_hWnd, WM_SETTEXT_CUSTOM, 0, (LPARAM)m_titleTextBuffer);
|
||||
PostMessage(m_hWnd, WM_SETTEXT_CUSTOM, 0, (LPARAM)text.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user