char* CButtonControl::GetText()
{
char* buffer = NULL ;
int length ;
length = SendMessage(hwnd, WM_GETTEXTLENGTH, 0, 0) ;
SendMessage(hwnd, WM_GETTEXT, length, (LPARAM)buffer) ;
return buffer ;
}
[source]
WM_GETTEXT help
hmm...how come this doesnt work:
From the documentation for WM_GETTEXT:
The most important part to observe in the above is "a buffer provided by the caller"
You already get the length using GETTEXTLENGTH so you know how big to make the buffer, so just after that do something like:
buffer = new char[length];
and then remember to delete[] that buffer when the caller of your function has finished with it.
If CButtonControl inherits from any MFC classes, make sure that the hWnd is valid (use CWnd::GetSafeHwnd).
--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com
quote:
An application sends a WM_GETTEXT message to copy the text that corresponds to a window into a buffer provided by the caller.
The most important part to observe in the above is "a buffer provided by the caller"
You already get the length using GETTEXTLENGTH so you know how big to make the buffer, so just after that do something like:
buffer = new char[length];
and then remember to delete[] that buffer when the caller of your function has finished with it.
If CButtonControl inherits from any MFC classes, make sure that the hWnd is valid (use CWnd::GetSafeHwnd).
--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement