Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Drag an Image
Message
De
19/02/2009 11:43:45
 
 
À
19/02/2009 10:48:37
Jay Johengen
Altamahaw-Ossipee, Caroline du Nord, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Titre:
Divers
Thread ID:
01382908
Message ID:
01382926
Vues:
119
>>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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform