You should use either the mousex/mousey, or the mousemovex/mousemovey but not both as they don't always give the same measurements.
You also have a slight problem with the sequence that you are processing in - you always display what happened in the last frame, not the current frame.
Try this code instead
sync on
sync rate 0
Set window off
x1 =100
y1 =100
x2 =200
y2 =200
clicked=0
offsetx=0
offsety=0
do
cls
mousePosX=mousex()
mousePosY=mousey()
if mousePosX>x1 and mousePosX<x2 and mousePosY>y1 and mousePosY<y2 and mouseclick()=1
if clicked = 0
clicked=1
offsetx = mousePosX - x1
offsety = mousePosY - y1
endif
else
clicked=0
endif
if clicked = 1
x1 = mousePosX-offsetx
y1 = mousePosY-offsety
x2 = x1+100
y2 = y1+100
endif
box x1,y1,x2,y2
sync
loop
Watch out for typos - I manually copied this across.
*** Coming soon - Network Plug-in - Check my site for info ***
For free Plug-ins, source and the Interface library for Visual C++ 6, .NET and now for Dev-C++
http://www.matrix1.demon.co.uk