Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Smoothly moving an object
Message
De
24/12/2017 15:57:53
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Titre:
Smoothly moving an object
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows 10
Database:
Visual FoxPro
Divers
Thread ID:
01656712
Message ID:
01656712
Vues:
115
Hi all,

I want an object (now a label) to smoothly move to another location on the form. Based on the y,x coordinates of the label and of the position that the mouse is down, the object moves in 30 steps. However, only some of those steps are actually displayed. I get the impression that the refresh-rate of VFP is simply too low for such a type of smooth moving.

Any deas?
oform = Newobject("testmove")
oform.Show
Read Events

Define Class testmove As Form
	BorderStyle = 2
	Caption = "testmove"
	AlwaysOnTop = .T.
	BackColor = Rgb(255,255,255)
	Name = "testmove"
	scalemode = 3
	oObj = NULL
	width = 900
	height = 700

Procedure MouseDown
	Lparameters nButton, nShift, nXCoord, nYCoord
	this.moveobject( nXCoord, nYCoord )
	return

function init
	lcNewObjName = 'theObject'
	this.newobject( m.lcNewObjName, 'label' )
	this.oObj = this.&lcNewObjName
	this.&lcNewObjName..visible = .t.
	return

function queryunload
	clear dlls Sleep
	clear events
	return

function keypress
	LPARAMETERS nKeyCode, nShiftAltCtrl
	if inlist( nKeyCode, 27, 113, 32 )
		clear events
	endif
	return

function moveobject

	lparameter tnToLeft, tnToTop

	local lnStep, ln, lnT, lnL

	with this
		
		lnStep  = 30
		lnT = ( m.tnToTop  - .oObj.top  ) / m.lnStep
		lnL = ( m.tnToLeft - .oObj.left ) / m.lnStep
		
		with .oObj

			for ln = 1 to m.lnStep
				*
				.caption = transform( m.ln )
				.top  = .top  + m.lnT
				.left = .left + m.lnL
				*
				pause( 2 / m.lnStep )
			next

		endwith
	endwith

enddefine

FUNCTION Pause( tnSeconds )
	DECLARE Sleep in WIN32API integer
	Sleep( max( 0, tnSeconds ) * 1000 )
	RETURN
Groet,
Peter de Valença

Constructive frustration is the breeding ground of genius.
If there’s no willingness to moderate for the sake of good debate, then I have no willingness to debate at all.
Let's develop superb standards that will end the holy wars.
"There are three types of people: Alphas and Betas", said the beta decisively.
If you find this message rude or offensive or stupid, please take a step away from the keyboard and try to think calmly about an eventual a possible alternative explanation of my message.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform