From 78a2f32692a7db9d91fb37353c70882cd1519e44 Mon Sep 17 00:00:00 2001 From: "Adam D. Walling" Date: Thu, 30 Sep 2021 15:03:14 -0400 Subject: [PATCH] Fix status bar text display issue in dark mode Fix incorrect text size calculation for drawing the dark mode status bar which can cause an invalid character to be displayed. Fix #10564, close #10611 --- PowerEditor/src/WinControls/StatusBar/StatusBar.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/PowerEditor/src/WinControls/StatusBar/StatusBar.cpp b/PowerEditor/src/WinControls/StatusBar/StatusBar.cpp index d3fe1ad50..74aa6089c 100644 --- a/PowerEditor/src/WinControls/StatusBar/StatusBar.cpp +++ b/PowerEditor/src/WinControls/StatusBar/StatusBar.cpp @@ -154,8 +154,9 @@ LRESULT CALLBACK StatusBarSubclass(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l DWORD cchText = 0; cchText = LOWORD(SendMessage(hWnd, SB_GETTEXTLENGTH, i, 0)); - str.resize(cchText + 1); - LRESULT lr = SendMessage(hWnd, SB_GETTEXT, i, (LPARAM)str.data()); + str.resize(cchText + 1); // technically the std::wstring might not have an internal null character at the end of the buffer, so add one + LRESULT lr = SendMessage(hWnd, SB_GETTEXT, i, (LPARAM)&str[0]); + str.resize(cchText); // remove the extra NULL character bool ownerDraw = false; if (cchText == 0 && (lr & ~(SBT_NOBORDERS | SBT_POPOUT | SBT_RTLREADING)) != 0) {