7 Replies - 1280 Views - Last Post: 01 September 2012 - 02:43 AM

#1 Latias  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 73
  • Joined: 28-June 12

multi-lines with enter-space in editbox

Posted 29 August 2012 - 12:13 PM

hey

i want to know how to code a editbox which can hold multiple strings in a row.
i already checked the option multiple lines, but i want them in a row
i mean this

string1
string2
...
string10



i have read something about EM_REPLACESEL and EM_REPLACESE, but it doesnt not work for me. the string are still at the first line, and it when calling the second string it will replace the first one
i used this code to set the cursor to the next line

Invoke SendMessage, hEditBox, EM_REPLACESEL, TRUE, Addr CRLF ; defined in .const: CRLF	db 13,10


or

Invoke SendMessage, hEditBox, EM_REPLACESEL, TRUE, Addr CRLF

This post has been edited by Latias: 29 August 2012 - 12:17 PM


Is This A Good Question/Topic? 0
  • +

Replies To: multi-lines with enter-space in editbox

#2 GunnerInc  Icon User is offline

  • "Hurry up and wait"
  • member icon




Reputation: 858
  • View blog
  • Posts: 2,281
  • Joined: 28-March 11

Re: multi-lines with enter-space in editbox

Posted 29 August 2012 - 02:56 PM

An Edit control is a single line control by default.

Using CreateWindow:
    invoke  CreateWindowEx,
                WS_EX_CLIENTEDGE,
                offset szWndClsEdit,
                NULL,
                WS_CHILD or WS_VISIBLE or WS_TABSTOP \
                or ES_MULTILINE or ES_WANTRETURN or WS_VSCROLL,
                5, 5,
                200,200,
                hWin,
                NULL,
                hInst,
                NULL

You need to use the ES_MULTILINE and ES_WANTRETURN to make the control multi-line. The WS_VSCROLL adds a Vertical scroll bar.

Sounds like you are using a resource editor? So it would be like this:
Multiline == TRUE
WantCR == TRUE
ScrollBar == Vertical

With ES_WANTRETURN, when you type something and hit return, the caret will go to the next line.
Was This Post Helpful? 0
  • +
  • -

#3 Latias  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 73
  • Joined: 28-June 12

Re: multi-lines with enter-space in editbox

Posted 30 August 2012 - 04:52 AM

yes im using a resource editor. i did what you suggest but it is still not working for me.
dont know why but this i got (1001 is editbox)


.elseif eax==WM_COMMAND 
      	mov eax,wParam 

.ifeax == 1003

invoke SetDlgItemText, hWin,1001, Offset string
	Invoke SendMessage, 1001, EM_REPLACESEL, TRUE, Addr CRLF

Was This Post Helpful? 0
  • +
  • -

#4 GunnerInc  Icon User is offline

  • "Hurry up and wait"
  • member icon




Reputation: 858
  • View blog
  • Posts: 2,281
  • Joined: 28-March 11

Re: multi-lines with enter-space in editbox

Posted 30 August 2012 - 03:19 PM

Does your string contain Carrage Return/Linefeeds (ASCII 13, 10)? If not, then your string will be on one line. It does not automagically get put on multiple lines.
Does your string look similar to this:
string      db  "string1 string2  ... string10", 0


or similar to this:
string      db  "string1", 13, 10, "string2", 13, 10, ..., 13, 10, "string10", 0


Show the string you are trying to use.
Was This Post Helpful? 0
  • +
  • -

#5 Latias  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 73
  • Joined: 28-June 12

Re: multi-lines with enter-space in editbox

Posted 30 August 2012 - 11:35 PM

its defined as

string db "string1", 13, 10,0
string2 db "string2", 13, 10,0
Was This Post Helpful? 0
  • +
  • -

#6 GunnerInc  Icon User is offline

  • "Hurry up and wait"
  • member icon




Reputation: 858
  • View blog
  • Posts: 2,281
  • Joined: 28-March 11

Re: multi-lines with enter-space in editbox

Posted 31 August 2012 - 05:47 PM

I just realized what you are doing wrong. What is wrong with this:
Invoke SendMessage, 1001, EM_REPLACESEL, TRUE, Addr CRLF


Do you see it? What is the first parameter of SendMessage? It is the handle of the window to send the message to NOT the control ID!

I am also unsure exactly what you are trying to do, maybe explain a bit better.
Was This Post Helpful? 0
  • +
  • -

#7 GunnerInc  Icon User is offline

  • "Hurry up and wait"
  • member icon




Reputation: 858
  • View blog
  • Posts: 2,281
  • Joined: 28-March 11

Re: multi-lines with enter-space in editbox

Posted 31 August 2012 - 06:23 PM

This is what I used as a test:
.data
string1         db  "string1", 13, 10, 0
string2         db  "string2", 13, 10, 0
string3         db  "string3", 13, 10, 0
string4         db  "string4", 13, 10, 0
string5         db  "string5", 13, 10, 0
string6         db  "string6", 13, 10, 0

StringTable     dd  offset string1, offset string2, offset string3, offset string4, offset string5, offset string6

.data?
hEdit               dd ?


.code
...
...
...
.if eax==WM_INITDIALOG
		invoke  GetDlgItem, hDlg, IDC_EDIT
		mov     hEdit, eax

	.elseif eax==WM_COMMAND
        mov		edx,wParam
		movzx	eax,dx
		shr		edx,16
		.if edx==BN_CLICKED
			.if eax==IDC_BUTTON
                xor     ebx, ebx
                lea     esi, StringTable
        AddStrings:
                invoke 	SendMessage, hEdit, EM_SETSEL, -1, -1                      ;move caret to end of text
			    invoke 	SendMessage, hEdit, EM_REPLACESEL, FALSE, [esi + 4 * ebx]  ;append the new text
			    invoke 	SendMessage, hEdit, EM_SCROLLCARET, NULL, NULL             ;scroll down if needed
                inc     ebx
                cmp     ebx, 5
                jna     AddStrings
		    .endif 
        .endif

and the output:
Attached Image
Was This Post Helpful? 1
  • +
  • -

#8 Latias  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 73
  • Joined: 28-June 12

Re: multi-lines with enter-space in editbox

Posted 01 September 2012 - 02:43 AM

ooe stupid mistake from that handle

i got it working now :bananaman:

thanks again sir !
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1