Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Smoothly moving an object
Message
De
24/12/2017 17:34:20
 
 
À
24/12/2017 15:57:53
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows 10
Database:
Visual FoxPro
Divers
Thread ID:
01656712
Message ID:
01656713
Vues:
109
This message has been marked as a message which has helped to the initial question of the thread.
J'aime (1)
Quicly i tested your code:
1.the exact declaration of the API is (yours is lso available when dont know the exact dll can use win32api syntax)
declare integer Sleep in kernel32 integer
put it in the first line of your code and cut it in the function pause.its declared one time only.

2 in the function moveObject
cut this line:
pause( 2 / m.lnStep )  && and replace it with
sleep(20)   &&20 msec
and its all.with these 2 changes your code works perfectly.can test this(run and click on any point of the form,the label go smoothly to the click position.
Declare Integer  Sleep In Kernel32  Integer

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 )
          Sleep(20)
        Next

      Endwith
    Endwith

Enddefine

*Function Pause( tnSeconds )
  *DECLARE integer  Sleep in Kernel32  integer
 * Sleep( Max( 0, tnSeconds ) * 1000 )
 * Return
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform