I just started coding assembly and I would like to say that the all the tutorials help me a lot. But I need a little advice I'm currently creating an app that fills a multiline editbox with values from different locations (in registry and from files). The way I fill the edit box is like this :

CrLf db 0Dh,0Ah,0

invoke lstrcat,offset WriteInEdit, offset strLine1
invoke lstrcat,offset WriteInEdit, offset CrLf
invoke lstrcat,offset WriteInEdit, offset strLine2
invoke lstrcat,offset WriteInEdit, offset CrLf

invoke SetDlgItemText,hWnd,IDC_EDIT_RESULT,addr WriteInEdit

So I'm building a single string with crlf in it and then place it in the edit box. Is this the right way or is it better constantly write a line to the editbox ?
I couldn't find a lot tutorials about string functions and filling edit boxes etc so I hope that somebody give me some tips.
Posted on 2002-02-20 07:25:03 by s1l3nce
use the following code, this way you dont have to store everything in a (huge) buffer :
invoke GetDlgItem, hWnd, IDC_EDIT_RESULT

mov hEditResult, eax

invoke SendMessage,hEditResult,EM_SETSEL,0,-1 ; select all
invoke SendMessage,hEditResult,EM_SETSEL,-1,0 ; deselect, caret is now at end of text
invoke SendMessage,hEditResult,EM_REPLACESEL,FALSE,addr strLine1
you could make it a proc like:
AppendText proc dwhWnd:DWORD, lpBuffer:DWORD

invoke SendMessage,dwhWnd,EM_SETSEL,0,-1
invoke SendMessage,dwhWnd,EM_SETSEL,-1,0
invoke SendMessage,dwhWnd,EM_REPLACESEL,FALSE,lpBuffer
AppendText endp

;and call it with:
invoke AppendText, hWndEditResult, offset strLine1
invoke AppendText, hWndEditResult, offset CrLf
invoke AppendText, hWndEditResult, offset strLine2
invoke AppendText, hWndEditResult, offset CrLf
Good luck :alright:
Posted on 2002-02-20 08:03:37 by savage
Ok that will do it (bedankt ;) )
Posted on 2002-02-20 08:10:17 by s1l3nce