From 7f4fa540e140fc6cf3d65f70157bea3ceeb173e7 Mon Sep 17 00:00:00 2001 From: kervala Date: Tue, 25 Oct 2016 11:49:46 +0200 Subject: [PATCH] Changed: Display a warning when SetWindowTextW fails --HG-- branch : develop --- .../3d/driver/direct3d/driver_direct3d.cpp | 5 ++++- .../3d/driver/opengl/driver_opengl_window.cpp | 5 ++++- code/nel/src/misc/win32_util.cpp | 5 ++++- code/nel/src/misc/win_displayer.cpp | 19 ++++++++++++++++--- code/ryzom/client/src/init.cpp | 5 ++++- 5 files changed, 32 insertions(+), 7 deletions(-) diff --git a/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp b/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp index 2b90ea1ed..887034a9d 100644 --- a/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp +++ b/code/nel/src/3d/driver/direct3d/driver_direct3d.cpp @@ -2267,7 +2267,10 @@ bool CDriverD3D::getCurrentScreenMode(GfxMode &gfxMode) // *************************************************************************** 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()); + } } // *************************************************************************** diff --git a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp index 860f27353..1750c56e0 100644 --- a/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp +++ b/code/nel/src/3d/driver/opengl/driver_opengl_window.cpp @@ -2314,7 +2314,10 @@ void CDriverGL::setWindowTitle(const ucstring &title) #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) diff --git a/code/nel/src/misc/win32_util.cpp b/code/nel/src/misc/win32_util.cpp index 7631ac7b2..a99ca57d7 100644 --- a/code/nel/src/misc/win32_util.cpp +++ b/code/nel/src/misc/win32_util.cpp @@ -40,7 +40,10 @@ void CWin32Util::localizeWindow(HWND wnd) std::string winText = wideToUtf8(str); 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); diff --git a/code/nel/src/misc/win_displayer.cpp b/code/nel/src/misc/win_displayer.cpp index c9e81bbb3..37db08fbf 100644 --- a/code/nel/src/misc/win_displayer.cpp +++ b/code/nel/src/misc/win_displayer.cpp @@ -217,8 +217,13 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) ucstring ucs; // convert the text from UTF-8 to unicode ucs.fromUtf8(cwd->_History[cwd->_PosInHistory]); + // 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()); } } @@ -234,8 +239,13 @@ LRESULT CALLBACK WndProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) ucstring ucs; // convert the text from UTF-8 to unicode ucs.fromUtf8(cwd->_History[cwd->_PosInHistory]); + // 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()); } } @@ -352,7 +362,10 @@ void CWinDisplayer::setTitleBar (const string &titleBar) 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) diff --git a/code/ryzom/client/src/init.cpp b/code/ryzom/client/src/init.cpp index 240a70068..3f22ed956 100644 --- a/code/ryzom/client/src/init.cpp +++ b/code/ryzom/client/src/init.cpp @@ -257,7 +257,10 @@ static INT_PTR CALLBACK ExitClientErrorDialogProc(HWND hwndDlg, UINT uMsg, WPARA { 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 ()); if (CI18N::hasTranslation("uiRyzomErrorMsgBoxExit"))