what do you send to a edit control (using SetWindowText) to have it add a newline.

I send a string of ascii char's to it and get control char's instead of a newline.

ex.

invoke SetWindowText, hwndEdit, addr Text_Buffer
Where Text_Buffer ='s 0Dh,0Ah,0h

The response is two vertical bars || instead of a newline.


Any guesses?



Thanks
Posted on 2002-09-07 20:48:30 by sceptor
you probably forgot to add a style, ES_MULTILINE.
Posted on 2002-09-07 21:37:12 by stryker
I wish it was that easy.

WS_CHILD or WS_VISIBLE or WS_VSCROLL or ES_LEFT or ES_AUTOVSCROLL or ES_MULTILINE is how I created it.


I am guessing it just doesnt recognize control characters, but all I could find is:

The SetWindowText function does not expand tab characters (ASCII code 0x09). Tab characters are displayed as vertical bar (|) characters
Posted on 2002-09-07 21:54:26 by sceptor
[size=9]FORMAT PE GUI 4.0

entry start

INCLUDE '\fasm\include\kernel.inc'
INCLUDE '\fasm\include\user.inc'
INCLUDE '\fasm\include\macro\stdcall.inc'
INCLUDE '\fasm\include\macro\import.inc'

section '.idata' import data readable writeable
library kernel, 'KERNEL32.DLL',\
user, 'USER32.DLL'
kernel:
import GetModuleHandle,'GetModuleHandleA'

user:
import RegisterClass,'RegisterClassA',\
CreateWindowEx,'CreateWindowExA',\
DefWindowProc,'DefWindowProcA',\
GetMessage,'GetMessageA',\
TranslateMessage,'TranslateMessage',\
DispatchMessage,'DispatchMessageA',\
LoadCursor,'LoadCursorA',\
PostQuitMessage,'PostQuitMessage',\
SetWindowText,'SetWindowTextA'

start:

invoke LoadCursor, NULL, IDC_ARROW
mov [wc.hCursor], eax
mov [wc.lpfnWndProc], WindowProc
mov [wc.hbrBackground], COLOR_BTNFACE+1
mov [wc.lpszClassName], appclass
invoke RegisterClass, wc
invoke GetModuleHandle, NULL
mov [hInstance], eax
invoke CreateWindowEx, NULL, appclass, appclass, WS_VISIBLE+WS_OVERLAPPEDWINDOW,\
CW_USEDEFAULT, CW_USEDEFAULT, 200, 200, NULL, NULL, eax, NULL

__msg_lp:

invoke GetMessage, msg, NULL, 0, 0
test eax, eax
jz __msg_lp_ex
invoke TranslateMessage, msg
invoke DispatchMessage, msg
jmp __msg_lp

__msg_lp_ex:

retn

WindowProc:

EditID = 5000

push ebp
push esp
pop ebp

cmp DWORD [ebp+12], WM_CREATE
je __create
cmp DWORD [ebp+12], WM_DESTROY
je __destroy
pop ebp
jmp [DefWindowProc]

__create:

invoke CreateWindowEx, NULL, EditClassName, NULL, \
WS_CHILD + WS_VISIBLE + ES_LEFT + ES_MULTILINE + WS_VSCROLL,\
5, 5, 185, 165, DWORD [ebp+8], EditID, [hInstance], NULL
invoke SetWindowText, eax, text
jmp __lresult

__destroy:

invoke PostQuitMessage, NULL

__lresult:

xor eax,eax
leave
ret 16

appclass DB "editbox2", 0
EditClassName DB "edit", 0
text DB "Hello", 0Dh, 0Ah, 09h, "Cruel", 0Dh, 0Ah, "World", 0

wc WNDCLASS
msg MSG
hInstance DD ?[/size]
seems to work for me!!! :)
Posted on 2002-09-07 22:35:34 by stryker
I found it, strange though.

I had the CR/LF characters swapped in the string. Try sending 0D,0A instead of 0A,0D.
That should make it cough.

was:
text DB "Hello", 0Dh, 0Ah, 09h, "Cruel", 0Dh, 0Ah, "World", 0
now:
text DB "Hello", 0Ah, 0Dh, 09h, "Cruel", 0Ah, 0Dh, "World", 0

Any guess why it needs the "correct?" sequence?
Posted on 2002-09-08 07:23:46 by sceptor
hmm, I really don't know why your version isn't working(First One) but mine is

"Hello", 0Dh, 0Ah, 09h, "Cruel", 0Dh, 0Ah, "World", 0

which is the opposite of your current sequence(Second One).

Also PSDK says that SetWindowText doesn't expand tab characters but it seems to work for me. :confused:

BTW, I'm using Windows 200 SP3.
Posted on 2002-09-08 10:04:31 by stryker
Swap the 0D, and the 0A characters in your text string, and see what it does. On mine (win98 SE) it fails to decode them. It also does not expand the tab char in that case.

When I send 0A,0D,09,"some text",0 mine expands the tab character as well.
Posted on 2002-09-08 14:23:11 by sceptor
Yes if I swap 0Dh and 0Ah it fails to decode the CRLF and 2 vertical bars appears but it doesn't fail to decode the tab 09h.

I have never used SetWindowText. I use SendMessage with WM_SETTEXT or SetDlgItemText to place text on an edit control... SetDlgItemInt...

For the reason why that sequence 0Ah 0Dh 09h, I don't know. Probably 2 different set of codes of SetWindowText function on 2 different versions of user32.dll??? one is the win98 version, the other is the windows 2000 version???
Posted on 2002-09-08 15:16:55 by stryker