Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to drag and move command buttons inside a form
Message
De
16/09/2007 07:20:34
Erick Miranda
Formata Data Business - Grupo Linx
Contagem, Brésil
 
 
À
15/09/2007 23:02:16
Hee Lim Wang
Fantasy Software Enterprise
Malaisie
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
01254261
Message ID:
01254581
Vues:
15
Hi Hee,

>Thanks Erick
>but the button still cannot move to new position if i drop

It works fine here.
Put the code below in program file and run it.
LOCAL loForm as Form
m.loForm = CREATEOBJECT([formTest])
m.loForm.Show()

RETURN

*******************************************************************************

DEFINE CLASS formTest as Form
	nDifXCoord = 0
	nDifYCoord = 0
	
	*- Adding objects
	ADD OBJECT cmdExit as CommandButton
	ADD OBJECT cmdMove as CommandButton
	
	PROCEDURE init()
		WITH this
			.WindowType = 1
			.Caption 	= [Move the Button Below!]
			.Height 	= 421
			.Width 		= 656
			.AutoCenter = .T.
			
			*- Setting Exit button
			WITH .cmdExit
				.Caption = [\<Exit]
				.Height 	= 39
				.Width 		= 152
				.Top 		= 360
				.Left 		= 264
				.Visible 	= .T.
			ENDWITH
			
			*- Setting Move button
			WITH .cmdMove
				.Caption = [Move Me Within of the Form]
				.Height 	= 65
				.Width 		= 81
				.Top 		= 24
				.Left 		= 60
				.DragMode 	= 1
				.WordWrap 	= .T.
				.Visible 	= .T.
			ENDWITH

		ENDWITH
	ENDPROC
	
	PROCEDURE DragDrop()
		LPARAMETERS oSource, nXCoord, nYCoord

		oSource.Left = nXCoord - thisForm.nDifXCoord
		oSource.Top = nYCoord -  thisForm.nDifYCoord
	ENDPROC
	
	*- Exit button
	PROCEDURE cmdExit.Click()
		ThisForm.Release()
	ENDPROC
	
	*- Move button
	PROCEDURE cmdMove.MouseMove()
		LPARAMETERS nButton, nShift, nXCoord, nYCoord

		thisForm.nDifXCoord = nXCoord - THIS.Left
		thisForm.nDifYCoord = nYCoord - THIS.Top
	ENDPROC
ENDDEFINE
For more information about Drag and Drop see Creating Drag-and-Drop Controls in VFP help.
I hope it helps you.
Erick
Força Sempre!
Strength Always!
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform