WM_GETTEXT
wParam = (WPARAM) cchTextMax; /* number of bytes to copy */
lParam = (LPARAM) lpszText; /* address of buffer for text */
An application sends a WM_GETTEXT message to copy the text that corresponds to a window into a buffer provided by the caller.
cchTextMax
Value of wParam. Specifies the maximum number of bytes to be copied, including the terminating null character.
lpszText
Value of lParam. Points to the buffer that is to receive the text.
The return value is the number of bytes copied. It is CB_ERR if the message is sent to a combo box that has no edit control.
For an edit control, the text to be copied is the contents of the edit control. For a combo box, the text is the contents of the edit-control (or static-text) portion of the combo box. For a button, the text is the button name. For other windows, the text is the window title. To copy the text of an item in a list box, an application can use the LB_GETTEXT message.
When the WM_GETTEXT message is sent to a static control with the SS_ICON style, the handle of the icon will be returned in the first two bytes of the buffer pointed to by lpszText. This is true only if the WM_SETTEXT message has been used to set the icon.
This example copies text from an edit control to a buffer:
HWND hwndMyEdit;
char szBuffer[32];
hwndMyEdit = GetDlgItem(hdlg, ID_MYEDITCONTROL);
SendMessage(hdlg, WM_GETTEXT, sizeof(szBuffer),
(LPARAM) ((LPSTR) szBuffer));