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!
.data
ourect RECT<>
.data?
newx dd ?
newy dd ?
.
.
.
.code
invoke GetWindowRect,winhand4,addr ourect
push eax
push ecx
mov eax, ourect.left
mov ecx, ourect.top
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!
-bradHi.
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
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... :)thnx, works now!
-brad