News:

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

array

Started by george999, November 17, 2007, 08:03:39 PM

Previous topic - Next topic

george999

I want to put an array in edit box.But when i invoke SetDlgItemText,hWin,1000,array it put only first item.

item0    dd "1",0
item1    dd "2",0
item2    dd "3",0
       

array DWORD item0,item1, item2,0
...
invoke SetDlgItemText,hWin,1000,array

How can I put all  array in edit box ?



donkey

QuoteSetDlgItemText....

lpString
[in] Pointer to the null-terminated string that contains the text to be copied to the control.

Since your first item is null terminated the API assumes that the end of the first element is the end of the string to add. SetDlgItemTxt is not designed to handle arrays of strings only a single string. To put the array in you will have to write a routine that reads the array and writes it to the text box one at a time.

Donkey
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

ragdog

hi


use this


.const
item0    equ "1"
item1    equ "2"
item2    equ "3"

.data
array db item0,item1, item2,0




greets
ragdog

MichaelW

George,

Items that are to be displayed as text (strings) would normally be defined with DB instead of DD. MASM will return an error if you try to assign a string longer than 4 bytes to a DWORD, and for shorter strings MASM will reverse the order of the bytes, and encode nulls for any byte not defined. For example:

item1 dd “1�,0

Would be encoded as:

31000000h, 00000000h

So even if you left off the null termination there would still be a null byte to terminate the string after the “1�.

Also, to display the array as text with each element on a separate line, you could terminate all but the last element with a CRLF, something like this:

item0 db “1�,13,10
item1 db “2�,13,10
item2 db “3�,0

eschew obfuscation

george999

item1 dd “1�,0

Would be encoded as:

31000000h, 00000000h

So even if you left off the null termination there would still be a null byte to terminate the string after the “1�.


and if i put it in binary?

item0          db  00110001b

How will be encoded?

george999

In binary it's working... :lol

Mark Jones

Quote from: george999 on November 18, 2007, 03:57:58 AM
item1 dd “1�,0
and if i put it in binary?

item0          db  00110001b


Hello, note that "00110001b" could be a hexadecimal number... to explicitly define a number as binary, use the "y" post-fix, i.e. 00110001y
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08