mirror of
https://github.com/reactos/reactos.git
synced 2025-08-07 02:42:59 +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)
|
BOOL GetWindowText(BSTR& bstrText)
|
||||||
{
|
{
|
||||||
ATLASSERT(::IsWindow(m_hWnd));
|
ATLASSERT(::IsWindow(m_hWnd));
|
||||||
int length = ::GetWindowTextLength(m_hWnd);
|
INT length = ::GetWindowTextLengthW(m_hWnd);
|
||||||
if (!SysReAllocStringLen(&bstrText, NULL, length))
|
if (!::SysReAllocStringLen(&bstrText, NULL, length))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
::GetWindowText(m_hWnd, (LPTSTR)&bstrText[2], length);
|
if (::GetWindowTextW(m_hWnd, bstrText, length + 1))
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
::SysFreeString(bstrText);
|
||||||
|
bstrText = NULL;
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetWindowTextLength() const
|
int GetWindowTextLength() const
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue