mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
[SDK][ATL] Fix CWindow::GetWindowText method of BSTR (#3498)
- Fix generic text mapping for GetWindowText and GetWindowTextLength functions. - Fix the position. - Fix the length. - Fail elegantly if necessary. CORE-9281
This commit is contained in:
parent
6de330026c
commit
e24d3cc952
1 changed files with 7 additions and 4 deletions
|
@ -782,11 +782,14 @@ public:
|
|||
BOOL GetWindowText(BSTR& bstrText)
|
||||
{
|
||||
ATLASSERT(::IsWindow(m_hWnd));
|
||||
int length = ::GetWindowTextLength(m_hWnd);
|
||||
if (!SysReAllocStringLen(&bstrText, NULL, length))
|
||||
INT length = ::GetWindowTextLengthW(m_hWnd);
|
||||
if (!::SysReAllocStringLen(&bstrText, NULL, length))
|
||||
return FALSE;
|
||||
::GetWindowText(m_hWnd, (LPTSTR)&bstrText[2], length);
|
||||
return TRUE;
|
||||
if (::GetWindowTextW(m_hWnd, bstrText, length + 1))
|
||||
return TRUE;
|
||||
::SysFreeString(bstrText);
|
||||
bstrText = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
int GetWindowTextLength() const
|
||||
|
|
Loading…
Reference in a new issue