I have the following code :


sm STRUCT
iIndex DW ? ;
szLabel DB 50 DUP (0);
szDesc DB 50 DUP (0);
sm ENDS
.data
sysmetrics \
sm <SM_CXSCREEN, "SM_CXSCREEN","Screen width in pixels">
sm <SM_CYSCREEN, "SM_CYSCREEN","Screen height in pixels">
sm <SM_CXVSCROLL,"SM_CXVSCROLL","Vertical scroll width">
sm <SM_CYHSCROLL,"SM_CYHSCROLL","Horizontal scroll height">
sm <SM_CYCAPTION,"SM_CYCAPTION","Caption bar height">
sm <SM_CXBORDER,"SM_CXBORDER","Window border width">
sm <SM_CYBORDER, "SM_CYBORDER","Window border height">

NUMPOINT equ ($-sysmetrics)/sizeof sm




.ELSEIF eax==WM_PAINT
invoke BeginPaint,hWnd, addr ps
mov hdc,eax
push esi
mov esi,offset sysmetrics
assume esi: PTR sm
xor ecx,ecx
.repeat
push ecx
mov eax, cyChar
mul ecx
mov edx,eax
lea ebx,[esi].szLabel
mov al,[ebx]
xor ah,ah
.WHILE al
inc ah
inc ebx
mov al,[ebx]
.ENDW
xor ebx,ebx
mov bl,ah
invoke TextOut,hdc,0,edx,addr [esi].szLabel,ebx
add esi, sizeof sm
pop ecx
inc ecx
.until esi == NUMPOINT * sizeof sm
assume esi:nothing
pop esi
invoke EndPaint,hWnd,addr ps
ret

when I run the Program it shows only the first line and gives a windows error message.

1. where is the problem; I tried to solve this problem more the 3h :(

2. is there a better way to find the size of a sting ?

peace
Posted on 2004-10-01 05:45:52 by mistronr1
Use the StrLen supplied in the M32.LIB included with masm32.
You could also hardcode the string length in the structure, if it doesn't change.

I also see a space in your strings for Vertical scroll width, horizontal scroll width, etc. Might be a bad cut and paste tho.
Posted on 2004-10-07 09:34:52 by drarem
hi mistronr1

i just had a look at ur code and could not figure out why???


.WHILE al
inc ah
inc ebx
mov al,[ebx] <---------------this one
.ENDW

my question is can we put value of ebx (a register) in al (lower order bits of accumulator).
according to me its buggy there.if am wrong pay no heed to my post.
thank you
nickdigital
Posted on 2004-10-07 14:16:40 by nickdigital
...
my question is can we put value of ebx (a register) in al (lower order bits of accumulator).
according to me its buggy there.if am wrong pay no heed to my post.
thank you
nickdigital


The square brackets around ebx mean to load whatever is in memory at offset ebx into al. So in this case he loads the byte at offset ebx into al to check for the NULL terminator...the fact that ebx and al aren't the same size doesn't matter in this case.
Posted on 2004-10-07 15:15:55 by sirchess
hi sirchess,
thanks a lot for clearing my doubt.
nickdigital
Posted on 2004-10-07 15:29:20 by nickdigital
Hi guys
I did some changes to the code and still having some problems.

Drarem : I know I could use StrLen, but I want to be able to do it my selv to, I realy need to understand how addressing works in a strucutre, and by the way the space at the end of each line shouldn't matter, it has to be treated as part of the string (I guess).
OK the application writes the first line and the something goes wrong, I am trying to translate some code from from windows programing by Charles Petzold.

thanks for all the replys

peace
Posted on 2004-10-11 21:40:35 by mistronr1
I think the problem is that you have to save and restore the EBX register before you invoke any windows function.
Posted on 2004-10-14 05:20:59 by GorillaCoder