The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Lightman on June 02, 2010, 08:32:06 AM

Title: Dumb edit box question of the day.
Post by: Lightman on June 02, 2010, 08:32:06 AM
Hi Everybody,

Is there a way to add multiple lines to an edit box?  I can create a multiline edit box and assign text to it.  But when I add more text it overwrites the current text.


...
sLoadMsg   db   'Loading Picture One...', 10, 13, 0
sSaveMsg   db   'Saving Picture One...', 10, 13, 0
...

...
invoke   SendMessage, hEdit, WM_SETTEXT, 0, addr sLoadMsg
invoke   SendMessage, hEdit, WM_SETTEXT, 0, addr sSaveMsg
...


Is there another API call for this?

Regards,

L.
Title: Re: Dumb edit box question of the day.
Post by: jj2007 on June 02, 2010, 09:44:58 AM
invoke SendMessage, hEdit, EM_SETSEL, -1, 0 ; select end of current text
invoke SendMessage, hEdit, EM_REPLACESEL, 0, chr$("appended")
Title: Re: Dumb edit box question of the day.
Post by: qWord on June 02, 2010, 10:20:20 AM
for appending lines:
MLEditAddLineA proc uses ebx esi hWnd:HANDLE,psz:ptr BYTE

.repeat
mov esi,rv(SendMessage,hWnd,WM_GETTEXTLENGTH,0,0)
add esi,len(psz)
lea esi,[esi+3]
.break .if !ASM(mov ebx,alloc(esi))
.if rv(SendMessage,hWnd,WM_GETTEXT,esi,ebx)
invoke szCatStr,ebx,chr$(13,10)
.endif
invoke szCatStr,ebx,psz
invoke SendMessage,hWnd,WM_SETTEXT,0,ebx
free(ebx)
mov eax,esi
.until
ret

MLEditAddLineA endp
Title: Re: Dumb edit box question of the day.
Post by: Lightman on June 02, 2010, 03:41:05 PM
Thanks guys.... That works Ok for me...