Hi, this is my first post here, English is not my primary language so sorry for possible mistakes.
I have been working around this since this morning and now I am asking for a little of your help
I am trying to get the text content of an EDIT control and store it into a LPTSTR global variable. What is strange is that I can get the length of the text inside the EDIT control but not the text itself. So this is my code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
|
LPTSTR dec;
HWND hwndEdit1;
int len1;
'
'
'WinMain and other irrelevant stuff for this issue
'
'
'
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
switch (message) {
case WM_CREATE:
hWndEdit1 = CreateWindowEx(WS_EX_CLIENTEDGE,"EDIT", "",
WS_VISIBLE|WS_CHILD|ES_MULTILINE|ES_AUTOVSCROLL,
5,30,585,150,hWnd, HMENU(5), hInstance, 0);
break;
case WM_COMMAND:
if(((HWND)lParam) && (HIWORD(wParam) == BN_CLICKED)) {
switch(LOWORD(wParam)) {
case 1:
len1 = GetWindowTextLength(hwndChild1);
GetWindowText(hWndEdit1, dec, len1);
break;
}
}
}
|
As I said, it get me the length of the EDIT right but the
dec variable remains empty after
GetWindowText. I tryied getting the EDIT content with
SendMessage(WM_GETTEXT) but the application crashes. With
SendMessageTimeout the result is the same as with GetWindowText:
dec remains empty.
I am a C++ beginner and I just got in love with this programming language. For the sake of this "love story" give me some clues (I don't suppose getting a text from an EDIT is something so difficult). Thank you so much in advance!
I won't sleep until I get this solved.