Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

WHO REMEMBER this old window 1

Status
Not open for further replies.

sal21

Programmer
Apr 26, 2004
411
0
16
IT
In effect i need to simulate the animation of the movement of withe icon from x,y to xx,yy, just one cicle.

start from x,y to xx,yy

note:
dont consider the dir icon and trash icon
i just have a withe icon in a form in a position x,y, is an image1/image
 
 https://files.engineering.com/getfile.aspx?folder=56994ec4-f16a-4d98-b80a-24e35778eaa4&file=ANIMAZIONE.jpg
So the 'old window' isn't really relevant? Since it is an AVI animation, whilst you just want to animate an image control from one place to another. Pretty straight forward, try something like

Code:
Option Explicit
Dim dx As Double
Dim dy As Double
Dim maxtime As Long
Dim aniControl As Control
  
Private Sub Command1_Click()
    BuildAnimation Image1, 24, 56, 576, 56, 2000, 60
End Sub

Private Sub BuildAnimation(myControl As Control, x, y, xx, yy, Optional mtime As Long = 1000, Optional granularity As Long = 100)
    Set aniControl = myControl
    maxtime = mtime
    dx = (xx - x) / (mtime / granularity)
    dy = (yy - y) / (mtime / granularity)
    aniControl.Move x, y
    aniTimer.Interval = granularity
    aniTimer.Enabled = True
End Sub

Private Sub aniTimer_Timer()
    Static looped As Long
    If looped = 0 Then aniControl.Visible = True
    If looped < maxtime Then
        aniControl.Move aniControl.Left + dx, aniControl.Top + dy
        looped = looped + aniTimer.Interval
    Else
        aniTimer.Enabled = False
        aniControl.Visible = False
        looped = 0
    End If
End Sub

Private Sub Form_Load()
    Form1.ScaleMode = vbPixels
End Sub

And that'll end up looking pretty much like this animation
 
the mtime parameter is the duration of the animation in milliseconds. The code already does all the heavy lifting concerning the distance between start and end points
 
Ok
But i need to use in form and not over control.
I see a control similar a button, where the animation run.
I need to set the initial and the and position of the animation on a form.
 
It isn't over a control. That's me faking one with a few graphic lines drawn directrly onto the form. Have you actually tried the code? At all?
 
Yes, tried.
With your code the finish of animation go out the form!
I can upload my zipped project?
 
I despair. You list yourself as a programmer, and yet somehow struggle with basics - yes, the animation will "go out the form" if the form is too small. This can be fixed by either changing the start and/or endpoints of the animation (x,y an xx,yy) to ensure they lie inside the form, or by making the form bigger
.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top