Changed: Display a warning when SetWindowTextW fails

This commit is contained in:
kervala 2016-10-25 11:49:46 +02:00
parent b1fb6d2ec2
commit c0a63db70c
5 changed files with 32 additions and 7 deletions

View file

@ -2267,7 +2267,10 @@ bool CDriverD3D::getCurrentScreenMode(GfxMode &gfxMode)
// *************************************************************************** // ***************************************************************************
void CDriverD3D::setWindowTitle(const ucstring &title) void CDriverD3D::setWindowTitle(const ucstring &title)
{ {
SetWindowTextW(_HWnd,(WCHAR*)title.c_str()); if (!SetWindowTextW(_HWnd, (WCHAR*)title.c_str()))
{
nlwarning("SetWindowText failed: %s", formatErrorMessage(getLastError()).c_str());
}
} }
// *************************************************************************** // ***************************************************************************

View file

@ -2314,7 +2314,10 @@ void CDriverGL::setWindowTitle(const ucstring &title)
#ifdef NL_OS_WINDOWS #ifdef NL_OS_WINDOWS
SetWindowTextW(_win, (WCHAR*)title.c_str()); if (!SetWindowTextW(_win, (WCHAR*)title.c_str()))
{
nlwarning("SetWindowText failed: %s", formatErrorMessage(getLastError()).c_str());
}
#elif defined(NL_OS_MAC) #elif defined(NL_OS_MAC)

View file

@ -40,7 +40,10 @@ void CWin32Util::localizeWindow(HWND wnd)
std::string winText = wideToUtf8(str); std::string winText = wideToUtf8(str);
if (CI18N::hasTranslation(winText)) if (CI18N::hasTranslation(winText))
{ {
SetWindowTextW(wnd, (const WCHAR *) CI18N::get(winText).c_str()); if (!SetWindowTextW(wnd, (const WCHAR *) CI18N::get(winText).c_str()))
{
nlwarning("SetWindowText failed: %s", formatErrorMessage(getLastError()).c_str());
}
} }
} }
HWND currSon = GetWindow(wnd, GW_CHILD); HWND currSon = GetWindow(wnd, GW_CHILD);

View file

@ -217,8 +217,13 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
ucstring ucs; ucstring ucs;
// convert the text from UTF-8 to unicode // convert the text from UTF-8 to unicode
ucs.fromUtf8(cwd->_History[cwd->_PosInHistory]); ucs.fromUtf8(cwd->_History[cwd->_PosInHistory]);
// set the text as unicode string // set the text as unicode string
SetWindowTextW(cwd->_HInputEdit, (LPCWSTR)ucs.c_str()); if (!SetWindowTextW(cwd->_HInputEdit, (LPCWSTR)ucs.c_str()))
{
nlwarning("SetWindowText failed: %s", formatErrorMessage(getLastError()).c_str());
}
SendMessageA (cwd->_HInputEdit, EM_SETSEL, (WPARAM)ucs.size(), (LPARAM)ucs.size()); SendMessageA (cwd->_HInputEdit, EM_SETSEL, (WPARAM)ucs.size(), (LPARAM)ucs.size());
} }
} }
@ -234,8 +239,13 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
ucstring ucs; ucstring ucs;
// convert the text from UTF-8 to unicode // convert the text from UTF-8 to unicode
ucs.fromUtf8(cwd->_History[cwd->_PosInHistory]); ucs.fromUtf8(cwd->_History[cwd->_PosInHistory]);
// set the text as unicode string // set the text as unicode string
SetWindowTextW(cwd->_HInputEdit, (LPCWSTR)ucs.c_str()); if (!SetWindowTextW(cwd->_HInputEdit, (LPCWSTR)ucs.c_str()))
{
nlwarning("SetWindowText failed: %s", formatErrorMessage(getLastError()).c_str());
}
SendMessageA (cwd->_HInputEdit, EM_SETSEL, (WPARAM)ucs.size(), (LPARAM)ucs.size()); SendMessageA (cwd->_HInputEdit, EM_SETSEL, (WPARAM)ucs.size(), (LPARAM)ucs.size());
} }
} }
@ -352,7 +362,10 @@ void CWinDisplayer::setTitleBar (const string &titleBar)
nldebug("SERVICE: Set title bar to '%s'", wn.c_str()); nldebug("SERVICE: Set title bar to '%s'", wn.c_str());
SetWindowTextW (_HWnd, (LPWSTR)ucstring::makeFromUtf8(wn).c_str()); if (!SetWindowTextW(_HWnd, (LPWSTR)ucstring::makeFromUtf8(wn).c_str()))
{
nlwarning("SetWindowText failed: %s", formatErrorMessage(getLastError()).c_str());
}
} }
void CWinDisplayer::open (string titleBar, bool iconified, sint x, sint y, sint w, sint h, sint hs, sint fs, const std::string &fn, bool ww, CLog *log) void CWinDisplayer::open (string titleBar, bool iconified, sint x, sint y, sint w, sint h, sint hs, sint fs, const std::string &fn, bool ww, CLog *log)

View file

@ -257,7 +257,10 @@ static INT_PTR CALLBACK ExitClientErrorDialogProc(HWND hwndDlg, UINT uMsg, WPARA
{ {
if (CI18N::hasTranslation("TheSagaOfRyzom")) if (CI18N::hasTranslation("TheSagaOfRyzom"))
{ {
SetWindowTextW(hwndDlg, (WCHAR*)CI18N::get ("TheSagaOfRyzom").c_str ()); if (!SetWindowTextW(hwndDlg, (WCHAR*)CI18N::get ("TheSagaOfRyzom").c_str ()))
{
nlwarning("SetWindowText failed: %s", formatErrorMessage(getLastError()).c_str());
}
} }
SetDlgItemTextW(hwndDlg, IDC_ERROR_MSG_TEXT, (WCHAR*) CurrentErrorMessage.c_str ()); SetDlgItemTextW(hwndDlg, IDC_ERROR_MSG_TEXT, (WCHAR*) CurrentErrorMessage.c_str ());
if (CI18N::hasTranslation("uiRyzomErrorMsgBoxExit")) if (CI18N::hasTranslation("uiRyzomErrorMsgBoxExit"))