Win32 EM_GETLINE

Started by
5 comments, last by DefCom 20 years, 8 months ago
I have never had to do much with win32 other than create a window for directX purposes, but i decided it was time to start learning how to do the GUI stuff (Visual C++). I have a edit box (CreateWindow(...)) and i would like to get the text/String data from it. I have been trying to use the SendMessage(hwnd, EM_GETLINE.... but i just don''t seem to understand how to wotk with it, if anyone could help, it would be much appriciated, Thanks.
Advertisement
I suppose you are implementing it like this:
char char_array[1000]={0};int line_number=0;//...SendMessage(hEdit,EM_GETLINE,line_number,char_array); 

It should work, but if it doesn''t then do this:
SendMessage(hEdit,WM_GETTEXT,num_characters,char_array); 
Thanks, but all i get is "Cannot convert char[] to long"
Hmmm, sorry about that, I guess you would use a pointer to the buffer.

Ayway, just use this if you want to get the whole contents of the edit control: GetDlgItemText(hwnd,IDC_EDIT,char_array,1000);
quote:Original post by Xiachunyi
char char_array[1000]={0};
int line_number=0;
//...
SendMessage(hEdit,EM_GETLINE,line_number,char_array);


That should be:

SendMessage(hEdit, EM_GETLINE, (WPARAM)line_number, (LPARAM)char_array);


Qui fut tout, et qui ne fut rien
Invader''s Realm
Hi,
Thanks Xiachunyi, thanks Invader X.
I must still be doing something wrong.
I create my text box with
hwndtext = CreateWindowEx(NULL,			"edit",			"hello",					WS_BORDER|WS_CHILD|WS_VISIBLE|ES_LEFT,			10,10,			100,100,			hWnd,			(HMENU)(100),			hInstance,			NULL); and then i 'Attempt' to get the data with   //if pushbuttonif(LOWORD(wParam)==101){        char char_array[1000]={0};	int line_number=0;		SendMessage(hwndtext, WM_GETTEXT, (WPARAM)line_number,(LPARAM)char_array); 						HDC hdc = GetDC(hwnd);	TextOut(hdc,220,140,char_array,1000);  					}


...but i am still not getting the data from the edit box. Any further help would be much appriciated, thanks again.

PS. I have tried WM_GETTEXT, EM_GETLINE and the GetDlgItemText() method.

[edited by - Defcom on August 15, 2003 5:29:14 AM]
I''ve fixed it.
HDC hdc = GetDC(hwnd);char* buf;int len;len = SendMessage (hwndtext, WM_GETTEXTLENGTH, 0, 0);SendMessage(hwndtext, EM_GETLINE, 0, (LPARAM)buf); TextOut(hdc,220,nextline,buf,len);nextline+=20;


Thanks again.

This topic is closed to new replies.

Advertisement