diff options
author | George Hazan <ghazan@miranda.im> | 2018-06-14 19:22:59 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2018-06-14 19:22:59 +0300 |
commit | 4c1ad067e0de275f1113aa1ee5368d7b528f0168 (patch) | |
tree | 59dff1f64037cb9ac80294a69d1cce9ef4e73993 /src/mir_core | |
parent | 6b496830f33360555adad192c4342d92bda458b1 (diff) |
code cleaning for CCtrlBase::GetText
Diffstat (limited to 'src/mir_core')
-rw-r--r-- | src/mir_core/src/CCtrlBase.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/mir_core/src/CCtrlBase.cpp b/src/mir_core/src/CCtrlBase.cpp index 83d7243ab6..9901ce0c68 100644 --- a/src/mir_core/src/CCtrlBase.cpp +++ b/src/mir_core/src/CCtrlBase.cpp @@ -125,23 +125,27 @@ void CCtrlBase::SetInt(int value) wchar_t* CCtrlBase::GetText() { - int length = GetWindowTextLength(m_hwnd) + 1; - wchar_t *result = (wchar_t *)mir_alloc(length * sizeof(wchar_t)); - GetWindowText(m_hwnd, result, length); + int length = GetWindowTextLengthW(m_hwnd); + wchar_t *result = (wchar_t *)mir_alloc((length+1) * sizeof(wchar_t)); + if (length) + GetWindowTextW(m_hwnd, result, length+1); + result[length] = 0; return result; } char* CCtrlBase::GetTextA() { - int length = GetWindowTextLength(m_hwnd) + 1; - char *result = (char *)mir_alloc(length * sizeof(char)); - GetWindowTextA(m_hwnd, result, length); + int length = GetWindowTextLengthA(m_hwnd); + char *result = (char *)mir_alloc((length+1) * sizeof(char)); + if (length) + GetWindowTextA(m_hwnd, result, length+1); + result[length] = 0; return result; } wchar_t* CCtrlBase::GetText(wchar_t *buf, int size) { - GetWindowText(m_hwnd, buf, size); + GetWindowTextW(m_hwnd, buf, size); buf[size - 1] = 0; return buf; } @@ -155,9 +159,9 @@ char* CCtrlBase::GetTextA(char *buf, int size) int CCtrlBase::GetInt() { - int length = GetWindowTextLength(m_hwnd) + 1; + int length = GetWindowTextLengthW(m_hwnd) + 1; wchar_t *result = (wchar_t *)_alloca(length * sizeof(wchar_t)); - GetWindowText(m_hwnd, result, length); + GetWindowTextW(m_hwnd, result, length); return _wtoi(result); } |