Board index » delphi » How to add multiple lines to multiline edit?

How to add multiple lines to multiline edit?

I create edit like this:

hEdit : HWND      // handle of main edit

hEdit:=CreateWindowEx(WS_EX_CLIENTEDGE,'Edit','',
WS_VISIBLE or WS_CHILD or ES_LEFT or ES_MULTILINE or
ES_WANTRETURN or ES_AUTOVSCROLL or
WS_VSCROLL,5,34,380,234,Handle,0,hInst,nil);

and add line with this:
SendMessage(hEdit,WM_SETTEXT,0,Longint(PChar('Test')));

but it replaces old text of edit.
How to add new line?

T.Hakala

 

Re:How to add multiple lines to multiline edit?


Quote
In article <8hh0ci$n4...@news.kolumbus.fi>, "@dev" <N...@EMAIL.NO> writes:
>I create edit like this:

>hEdit : HWND      // handle of main edit

>hEdit:=CreateWindowEx(WS_EX_CLIENTEDGE,'Edit','',
>WS_VISIBLE or WS_CHILD or ES_LEFT or ES_MULTILINE or
>ES_WANTRETURN or ES_AUTOVSCROLL or
>WS_VSCROLL,5,34,380,234,Handle,0,hInst,nil);

>and add line with this:
>SendMessage(hEdit,WM_SETTEXT,0,Longint(PChar('Test')));

>but it replaces old text of edit.
>How to add new line?

If you _must_ do it this way (and Delphi is marketed to save you getting
involved in all this {*word*193}, dirty Windows stuff) then either you use WM_GETTEXT
to obtain the existing text, add a CRLF and the new text and _then_ use
WM_SETTEXT, or you use LB_ADDSTRING or LB_INSERTSTRING.

Delphi would just use ListBox1.Items.Add('Test').

Alan Lloyd
alangll...@aol.com

Re:How to add multiple lines to multiline edit?


Use EM_SETSEL to set the selection markers to the end of the text and
EM_REPLACESEL to add text.

"@dev" <N...@EMAIL.NO> schreef in bericht
news:8hh0ci$n40$1@news.kolumbus.fi...

Quote
> I create edit like this:

> hEdit : HWND      // handle of main edit

> hEdit:=CreateWindowEx(WS_EX_CLIENTEDGE,'Edit','',
> WS_VISIBLE or WS_CHILD or ES_LEFT or ES_MULTILINE or
> ES_WANTRETURN or ES_AUTOVSCROLL or
> WS_VSCROLL,5,34,380,234,Handle,0,hInst,nil);

> and add line with this:
> SendMessage(hEdit,WM_SETTEXT,0,Longint(PChar('Test')));

> but it replaces old text of edit.
> How to add new line?

> T.Hakala

Other Threads