A better version that wont let the mouse arrow jump to top left of the picture.
REM
DEFLNG A-Z
DIM SHARED mx, my, mbl, mbr
video& = _NEWIMAGE(800, 600, 32)
image& = _LOADIMAGE("qb64logo.png", 32)
SCREEN video&
x1 = 100: x2 = x1 + 167: y1 = 100: y2 = y1 + 126
DO
_LIMIT 30
MousePoll
_PUTIMAGE (x1, y1)-(x2, y2), image&, video&
'check for mouse button down
IF mbl = -1 THEN
IF mx > x1 AND mx < x2 THEN
IF my > y1 AND my < y2 THEN 'mouse over picture
CLS
difx = mx - x1: dify = my - y1 'difference between x1 and mx ,y1 and my
WHILE mbl = -1
MousePoll
x1 = mx - difx: y1 = my - dify: x2 = x1 + 157: y2 = y1 + 126
LINE (x1 - 1, y1 - 1)-(x2 + 1, y2 + 1), _RGB32(255, 255, 0), B
_PUTIMAGE (x1, y1)-(x2, y2), image&, video&
PRINT x1, x2, difx, dify, mx, my
_DISPLAY
CLS
WEND
END IF
END IF
END IF
_DISPLAY
LOOP UNTIL _KEYDOWN(27)
SLEEP
SYSTEM
SUB MousePoll ()
DO WHILE _MOUSEINPUT
mx = _MOUSEX: my = _MOUSEY: mbl = _MOUSEBUTTON(1): mbr = _MOUSEBUTTON(2)
LOOP
END SUB
The picture:
http://dl.dropbox.com/u/10291175/qb64logo.png Edit:
I don't know if this works or not, use it at your own risk. From Garry