Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Drag an Image
Message
From
19/02/2009 11:43:45
 
 
To
19/02/2009 10:48:37
Jay Johengen
Altamahaw-Ossipee, North Carolina, United States
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Title:
Miscellaneous
Thread ID:
01382908
Message ID:
01382926
Views:
120
>>How can I make an image on a form movable? I want the user to be able to drag it around on the screen and have it stay there as >>long as the form is still open.

Use the MouseDown(), MouseUp() and MouseMove() events, record where the move mouse to and move image that far;

Requires a couple of new properties, mousedownx & mousedownY
*MouseDown()
LPARAMETERS nButton, nShift, nXCoord, nYCoord
IF nButton = 1
  THIS.mousedownx = m.nXCoord
  THIS.mousedownY = m.nYCoord
ENDIF

*MouseMove()
LPARAMETERS nButton, nShift, nXCoord, nYCoord
LOCAL lnDifferenceX, lnDifferenceY
IF nButton = 1 AND (THIS.mousedownx != 0 OR THIS.mousedowny != 0)
  m.lnDifferenceX = m.nXCoord - THIS.mousedownx
  m.lnDifferenceY = m.nYCoord - THIS.mousedowny
  THIS.Move(THIS.LEFT + m.lnDifferenceX, THIS.TOP + m.lnDifferenceY, This.Width, This.Height)
  THIS.MouseDown(nButton, nShift, nXCoord - m.lnDifferenceX, nYCoord - m.lnDifferenceY)
ENDIF

*MouseUp()
LPARAMETERS nButton, nShift, nXCoord, nYCoord
THIS.mousedownx = 0
THIS.mousedownY = 0
I can't take credit for the code, it came from a sample of moving a form without a titlebar. Think it might have been Craig Boyd's.


Gary.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform