Hello !
I'm having a problem with EM_GETLINE. I have a textbox I want to extract the text from. The box keeps updating all the time (it's a log file thet keeps updating, last message at the bottom). All I want is that very last line.
My code:
HWND hwnd = (HWND)0x00050440;
char display[256];
LONG lResult;
TCHAR tszString[256];
int nLines = SendMessageW(hwnd, EM_GETLINECOUNT, 0, 0)-1;
lResult = SendMessageW( hwnd, EM_GETLINE, nLines, (LPARAM)tszString);
int nLength = SendMessageW(hwnd, EM_GETLINE, (WPARAM)nLines, (LPARAM)tszString);
tszString[nLength] = '\0';
wcstombs(display, tszString, 256);
printf( " %s\n", display );
I keep getting 0 for nLength. MSDN say thats because I adress a linenumber larger than lines found in the textbox. Thats not the case.
The handle is correct, when using GETTEXT I get all the text from the box. ( Testing it on notepad...)
I'm not sure if I have initialized the buffer correct.
MSDN: "Before sending the message, set the first word of this buffer to the size, in TCHARs, of the buffer." :confused:
Right now the result is a empty console. No text... :((
I have Unicode set as characterset in my project, could that be a problem?
Regards
SH