News:

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

help with a loop / loop reset and window width

Started by j00n, February 15, 2011, 11:04:52 PM

Previous topic - Next topic

j00n

I need help understanding how to use cmp in the right way

I'm using a timer and LineTo to draw a line on the screen and scroll across and start over once it reaches the other side

.ELSEIF uMsg==WM_TIMER

          inc timerTick
          invoke InvalidateRect, hWnd, NULL, TRUE
         
          mov ecx, timerTick
          cmp ecx, 800            ;is this right? if timerTick ==800 = 0 then jump to loc1
          jz loc1
         
          loc1:
          mov timerTick, 0


also with loc1: how do I know when that label ends? or does it just continue with all instructions below it?

can anyone also tell me the right way to get the window height / width

store that to a variable and display it in a messagebox...?


dedndave

it looks like you are using CMP as desired

GetWindowRect will get you the perimeter coordinates
GetClientRect will get you the client area coordinates

well - to display a value in a message box, you have to have a window to begin with   :P

dedndave

        .DATA?

pr RECT <>
; left             dd ?
; top              dd ?
; right            dd ?
; bottom           dd ?

        .CODE

        INVOKE  GetWindowRect,hWnd,offset pr

;fills the values in "pr" with the screen coordinates for the window defined by "hWnd"


if you want the dimensions, height = bottom-top, width = right-left

        mov     eax,pr.bottom
        sub     eax,pr.top
        mov     WinHeight,eax
        mov     eax,pr.right
        sub     eax,pr.left
        mov     WinWidth,eax


notice that functions that fill RECT structures do so with the right and bottom values EXCLUSIVELY
i.e. the returned screen coordinate value is one pixel to the right of the right edge of the window (or below the bottom)
that way, when you subtract, you do not need to add one to the result to get the dimension

the left and top members are INCLUSIVE

the results from above are binary values
to display them in decimal or hexidecimal ASCII form, you need to convert the binary values to strings
the masm32 package has macros to do this for you

        INVOKE  MessageBox,NULL,ustr$(eax),offset TitleString,MB_OK

;displays an unsigned decimal string

        INVOKE  MessageBox,NULL,uhex$(eax),offset TitleString,MB_OK

;displays an unsigned hexidecimal string


j00n

I just want to say thanks for the help, I got it working the way I wanted but now i'm off to study all available macros and i'm reading the masm manual too

the only macros that come with masm32 are in macros.asm only correct?

dedndave

in the  \masm32\help  folder, you will find a number of CHM files
it is a good idea to familiarize yourself with all of them - at least browse them, so you know what is in them
hlhelp.chm is another one that has a lot of good stuff   :P