News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

appending multiple lines to editbox

Started by ChillyWilly, August 09, 2009, 05:30:02 AM

Previous topic - Next topic

ChillyWilly

i have a program that i want to output data to an editbox
i tried setting the editbox to multiline
i want to post multiple results into the window using 10,13 to make a newline in between each entry
SetDlgItemText works if the string is

TestString db "this is line one",13,10,"this is line two",13,10,"this is line three",0
invoke SetDlgItemText,hWnd,IDC_OFFICE,addr officebuff

the editbox looks like this:
Quotethis is line one
this is line two
this is line three


but not if i do it like this

one db "this is line one",0
two db "this is line two",0
three db"this is line three",0
glue  db  "%s",10,13,"%s",10,13,"%s",10,13,0
.data?
TestString db 512 dup(?)

invoke wsprintf,addr TestString,addr glue,addr DlgName,addr DlgName,addr DlgName
invoke SetDlgItemText,hWnd,IDC_OFFICE,addr TestString


the editbox looks like this:
this is line onethis is line twothis is line three


also how do i append to the editbox to keep adding more data

Quotethis is line one
this is line two
this is line three

this is line four
this is line five
this is line six



sinsi

Maybe "13,10" and "10,13" have something to do with it? All you need is LF (10) I think.

edit: maybe not
Quote from: SDK
An application may direct a multiline edit control to add or remove a soft line break character (two carriage returns and a line feed) automatically at the end of wrapped-text lines. An application can turn this feature on or off by sending the edit control an EM_FMTLINES message. This message applies only to multiline edit controls and does not affect a line that ends with a hard line break (one carriage return and a line feed entered by the user). Also in multiline edit controls, an application can specify the ES_WANTRETURN style to request that the system insert a carriage return when the user presses the ENTER key in the edit control.
Light travels faster than sound, that's why some people seem bright until you hear them.

hutch--

Will,

Depending on which edit control you use and what setting you select for it you have different line terminators for them. A normal edit control usually uses a 13 10 pair. Look up the messages for the specific control you are using, send a mesage putting the caret at the end of the last line, append the line terminator then your next line of text.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

fearless

I use this to place caret at end of text (for next insertion of text)
Invoke SendMessage, hEditBox, EM_SETSEL,65535,65535
and this to add a new line:
Invoke SendMessage, hEditBox, EM_REPLACESEL, TRUE, Addr CRLF
with CRLF defined as a var or const:
CRLF db 13,10
ƒearless

drizz

.data
szCrLf db 13,10,0
.code

AddLine proc hOutEdt,szLine
.if szLine
invoke SendMessage,hOutEdt,EM_SETSEL,-1,TRUE
invoke SendMessage,hOutEdt,EM_REPLACESEL,0,szLine
.endif
invoke SendMessage,hOutEdt,EM_SETSEL,-1,TRUE
invoke SendMessage,hOutEdt,EM_REPLACESEL,0,addr szCrLf
ret
AddLine endp

AddLinef proc c hOutEdt,pFormat,vargs:VARARG
LOCAL pITextBuff
invoke GlobalAlloc,GPTR,1000h
mov pITextBuff,eax
;;invoke wvnsprintf,pITextBuff,1000h,pFormat,addr vargs
invoke wvsprintf,pITextBuff,pFormat,addr vargs
invoke AddLine,hOutEdt,pITextBuff
invoke GlobalFree,pITextBuff
ret
AddLinef endp


invoke AddLine,hOutEdt,addr one
invoke AddLine,hOutEdt,addr two
...
invoke AddLine,hOutEdt,T("%s+%s"),addr one,addr two
The truth cannot be learned ... it can only be recognized.