Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Smoothly moving an object
Message
From
24/12/2017 18:37:36
 
 
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows 10
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01656712
Message ID:
01656715
Views:
72
*dont wanted to update the previous codefor those already read it
*just tweaked your code with some adds for fun
Declare Integer  Sleep In Kernel32  Integer
Publi oform
oform = Newobject("testmove")
oform.Show
Read Events
Retu

Define Class testmove As Form
  BorderStyle = 2
  Caption = "testmove-click on any point of the form area"
  AlwaysOnTop = .T.
  BackColor = Rgb(255,255,255)
  Name = "testmove"
  ScaleMode = 3
  oObj = Null
  Width = 900
  Height = 700

  Procedure MouseDown
    Lparameters nButton, nShift, nXCoord, nYCoord
    With Thisform  &&draw a point (small rectangle)
      .ForeColor=255
      .DrawWidth=12  &&pen
      .FillStyle=0   &&solid
      .PSet(nXCoord,nYCoord)  &&draw
    Endwith
    This.moveobject( nXCoord, nYCoord )
  Endproc

  Function Init
    lcNewObjName = 'theObject'
    This.Newobject( m.lcNewObjName, 'label' )
    This.oObj = This.&lcNewObjName
    With This.oObj
      .Height=This.oObj.Width
      .BackStyle=0
      .FontSize=12
      .Width=130
      .FontBold=.T.
    Endwith
    This.&lcNewObjName..Visible = .T.
  Endproc

  Function QueryUnload
    Clear Dlls Sleep
    Clear Events
  Endfunc

  Function KeyPress
    Lparameters nKeyCode, nShiftAltCtrl
    If Inlist( nKeyCode, 27, 113, 32 )
      Clear Events
    Endif
  Endfunc

  Function moveobject
    Lparameter tnToLeft, tnToTop

    Rand(-1)
    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 )+" bla bla bla bla"
          .Top  = .Top  + m.lnT
          .Left = .Left + m.lnL
          *	pause( 2 / m.lnStep )
          Sleep(50)
          If .Rotation<=355
            .Rotation=.Rotation+5
          Else
            Rotation=0
          Endi
          .ForeColor=Rgb(255*Rand(),255*Rand(),255*Rand())
        Next
        .Rotation=0
        .ForeColor=0
        Thisform.Cls
      Endwith
    Endwith
  Endproc

Enddefine

*!*	Function Pause( tnSeconds )
*!*	  *DECLARE integer  Sleep in Kernel32  integer
*!*	  Sleep( Max( 0, tnSeconds ) * 1000 )
*!*	  Return
Happy christmas for all!
Previous
Reply
Map
View

Click here to load this message in the networking platform