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

That was kind of cool, but whenever I try to drag the image, it flies off the form in the direction I drag it.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform