Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Move object container inside a container
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows XP
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01367578
Message ID:
01367614
Vues:
37
This message has been marked as the solution to the initial question of the thread.
Hi Claudio,

Maybe something like this might get you started, it is a dirty solution thou, I din not put much thought onto it
loForm				= NEWOBJECT('myForm')
loForm.Show(1)

define class myForm AS Form

	Height					= 401
	Width					= 759
	DoCreate				= .T.
	BorderStyle				= 3
	Name					= "myForm"

	add object ctrParentContainer AS ParentContainer WITH ;
		Top						= 48, ;
		Left					= 25, ;
		Width					= 361, ;
		Height					= 110, ;
		Name					= "ctrParentContainer"

enddefine

define class ParentContainer as Container

	add object MovableContainer1 as MovableContainer with ;
		Top						= 16, ;
		Left					= 23, ;
		Width					= 100, ;
		Height					= 47, ;
		Name					= "MovableContainer1", ;
		RestrictHorizontal		= .f., ;
		RestrictVertical		= .f.
	
	add object MovableContainer2 as MovableContainer with ;
		Top						= 70, ;
		Left					= 23, ;
		Width					= 100, ;
		Height					= 47, ;
		Name					= "MovableContainer2", ;
		RestrictHorizontal		= .t., ;
		RestrictVertical		= .f.

	add object MovableContainer3 as MovableContainer with ;
		Top						= 16, ;
		Left					= 120, ;
		Width					= 100, ;
		Height					= 47, ;
		Name					= "MovableContainer3", ;
		RestrictHorizontal		= .f., ;
		RestrictVertical		= .t.

	add object MovableContainer4 as MovableContainer with ;
		Top						= 70, ;
		Left					= 120, ;
		Width					= 100, ;
		Height					= 47, ;
		Name					= "MovableContainer4", ;
		RestrictHorizontal		= .t., ;
		RestrictVertical		= .t.
enddefine


define class MovableContainer as Container
	Moving					= .f.
	Starting				= null
	RestrictHorizontal		= .f.
	RestrictVertical		= .f.
	
	add object lblCaption as Label with ;
		Top						= 1, ;
		Left					= 1, ;
		FontName				= 'ArialNarrow', ;
		FontSize				= 8, ;
		Enabled					= .f.
		
	PROCEDURE Init
		this.lblCaption.Caption	= 'Restrict X: ' + Transform(this.RestrictHorizontal) + ' Y: ' + Transform(this.RestrictVertical)
		this.Starting			= Createobject('Empty')
		Addproperty(this.Starting, 'X', null)
		Addproperty(this.Starting, 'Y', null)
		Addproperty(this.Starting, 'Left', null)
		Addproperty(this.Starting, 'Top', null)
	ENDPROC

	PROCEDURE MouseDown
		LPARAMETERS nButton, nShift, nXCoord, nYCoord

		if nButton = 1
			this.Moving			= .t.
			this.Starting.Left	= this.Left
			this.Starting.Top	= this.Top
			this.Starting.X		= nXCoord
			this.Starting.Y		= nYCoord
		endif
	ENDPROC


	PROCEDURE MouseUp
		LPARAMETERS nButton, nShift, nXCoord, nYCoord

		if nButton = 1
			this.Moving		= .f.
		endif
	ENDPROC


	PROCEDURE MouseMove
		LPARAMETERS nButton, nShift, nXCoord, nYCoord

		if this.Moving
			this.Left			= this.Starting.Left + Iif(this.RestrictHorizontal, 0, (nXCoord - this.Starting.X))
			this.Top			= this.Starting.Top + Iif(this.RestrictVertical, 0, (nYCoord - this.Starting.Y))
		endif
	ENDPROC
enddefine
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform