criky, dudes! Im trying to figure out how to move the cursor into the middle of the dialog box, so i have wiped up this lil code, but at the divs it seems to crash.... any help would be apreciated!

ourect      RECT<>

newx        dd ?
newy        dd ?


invoke GetWindowRect,winhand4,addr ourect
                      push eax
                      push ecx
                      mov eax, ourect.left
                      mov ecx,
                      add eax,ecx
                      mov ecx,2
                      div ecx
                      mov newx, eax
                      xor eax,eax
                      xor ecx,ecx
                      mov eax, ourect.right
                      mov ecx, ourect.bottom
                      add eax,ecx
                      mov ecx,2
                      div ecx
                      mov newy, eax
                      pop ecx
                      pop eax
                      invoke SetCursorPos,newx,newy
thanx in advance! -brad
Posted on 2001-05-04 17:17:00 by Rage9
Hi. The problem may be because div uses edx:eax. This op-code put values (remainders) in the edx. If there is no remainder, zero will be put in edx Is much better you use SHR ECX,1 to divide by 2. samples (much better):

   shr eax,1   ;divide by 2
   shr ecx,2   ;divide by 4
   shr ebx,3   ;divide by 8
   shr edx,4   ;divide by 16

good luck!! :)

This message was edited by wolfao, on 5/4/2001 6:18:16 PM
Posted on 2001-05-04 17:27:00 by wolfao
I discovered the problem! The problem is that before you call div ecx , the edx register has the value 1 !!!. Whenever edx has some value before the div call, it will occur a exception. I tried the code:

   mov eax,380
   mov ecx,2
   mov edx,1
   div ecx
Guess?..... Unhandled exception... If we clean edx before div call it will work fine Exam.:

   mov eax,380
   mov ecx,2
   xor edx,edx
   div ecx
By anyway... It's much better use shr to divide to multiples of 2 and shl to multiply to multiples of 2. Good luck! again... :)
Posted on 2001-05-04 18:48:00 by wolfao
thnx, works now! -brad
Posted on 2001-05-05 00:46:00 by Rage9