WHO REMEMBER this old window

User avatar
sal21
PlatinumLounger
Posts: 4336
Joined: 26 Apr 2010, 17:36

WHO REMEMBER this old window

Post by sal21 »

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
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78364
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: WHO REMEMBER this old window

Post by HansV »

Perhaps you can use the video at Windows folder animation.

Otherwise: Move to Trash
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4336
Joined: 26 Apr 2010, 17:36

Re: WHO REMEMBER this old window

Post by sal21 »

HansV wrote:
25 Feb 2022, 11:30
Perhaps you can use the video at Windows folder animation.

Otherwise: Move to Trash
tks.
but i need to via vb6 code, not with animation avi

User avatar
HansV
Administrator
Posts: 78364
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: WHO REMEMBER this old window

Post by HansV »

Sorry, no idea how to do that.
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4336
Joined: 26 Apr 2010, 17:36

Re: WHO REMEMBER this old window

Post by sal21 »

HansV wrote:
25 Feb 2022, 11:39
Sorry, no idea how to do that.
googling...

Here an example, but the picture run as randomized movement and the cycle is infinity...

I need to move only one time the icon from x, y to xx,yy

Code: Select all

Option Explicit
Private Const mSpeed As Single = 5
Private Sub Form_Load()

    With Picture1
        .AutoSize = True
        .BorderStyle = 0
        .BackColor = vbWhite
        .Picture = Me.Icon
    End With
    
    Timer1.Interval = 1
    Timer1.Enabled = True
    Me.ScaleMode = vbPixels
    Picture1.ScaleMode = vbPixels
    
End Sub
Private Sub Timer1_Timer()

Static GoingLeft As Boolean, GoingUp As Boolean
Dim NewX As Single, NewY As Single

    With Picture1
        If GoingLeft Then
            If .Left - mSpeed <= 0 Then
                NewX = .Left
                GoingLeft = False
            Else
                NewX = .Left - mSpeed
            End If
        Else
            If .Left + .ScaleWidth + mSpeed >= Me.ScaleWidth Then
                NewX = Me.ScaleWidth - .ScaleWidth
                GoingLeft = True
            Else
                NewX = .Left + mSpeed
            End If
        End If
        If GoingUp Then
            If .Top - mSpeed < 0 Then
                NewY = .Top
                GoingUp = False
            Else
                NewY = .Top - mSpeed
            End If
        Else
            If .Top + .ScaleHeight + mSpeed > Me.ScaleHeight Then
                NewY = Me.ScaleHeight - .ScaleHeight
                GoingUp = True
            Else
                NewY = .Top + mSpeed
            End If
        End If
        .Move NewX, NewY
    End With
    
End Sub


User avatar
HansV
Administrator
Posts: 78364
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: WHO REMEMBER this old window

Post by HansV »

See if this works. It is not the full solution, just a test. Form_Load is as above.

Code: Select all

Private Sub Timer1_Timer()
    With Picture1
        If .Left + .ScaleWidth + mSpeed >= Me.ScaleWidth Then
            Timer1.Enabled = False
        Else
            .Move .Left + mSpeed, .Top
        End If
    End With
End Sub
Best wishes,
Hans

User avatar
SpeakEasy
4StarLounger
Posts: 544
Joined: 27 Jun 2021, 10:46

Re: WHO REMEMBER this old window

Post by SpeakEasy »

Just a pedantic point:

>but i need to via vb6 code, not with animation avi
The animation you used as an example is indeed an AVI - and one that is included with VB6 to be used by the VB6 animation control (this being the same AVI linked to by Hans), e.g (assuming a form with a command button and an animation control):

Code: Select all

Option Explicit

Private Sub Command1_Click()
With Animation1
      .AutoPlay = True
      .Open "C:\Program Files\Microsoft Visual Studio\Common\Graphics\Videos\filedel.avi"
   End With
End Sub

User avatar
sal21
PlatinumLounger
Posts: 4336
Joined: 26 Apr 2010, 17:36

Re: WHO REMEMBER this old window

Post by sal21 »

HansV wrote:
25 Feb 2022, 12:49
See if this works. It is not the full solution, just a test. Form_Load is as above.

Code: Select all

Private Sub Timer1_Timer()
    With Picture1
        If .Left + .ScaleWidth + mSpeed >= Me.ScaleWidth Then
            Timer1.Enabled = False
        Else
            .Move .Left + mSpeed, .Top
        End If
    End With
End Sub
bro the code work perfect!

but now i need to set the coordinate from the start and to the and in a form. see image for example.
choice you the start x,y and and xx,yy in form

note:
I had no doubts about your abilities! :evilgrin:
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78364
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: WHO REMEMBER this old window

Post by HansV »

Try this. Change xSpeed, x1, y1, x2 and y2 as you prefer.

Code: Select all

Const xSpeed As Single = 5
Dim ySpeed As Single

' Start Position
Const x1 As Single = 20, y1 As Single = 25
' End position
Const x2 As Single = 200, y2 As Single = 100

Private Sub Form_Load()
    Me.ScaleMode = vbPixels
    With Picture1
        .ScaleMode = vbPixels
        .AutoSize = True
        .BorderStyle = 0
        .BackColor = vbWhite
        .Picture = Me.Icon
        ' Set the start position
        .Left = x1
        .Top = x2
    End With
    
    With Timer1
        .Interval = 1
        .Enabled = True
    End With
    
    ySpeed = (y2 - y1) / (x2 - x1) * xSpeed
End Sub

Private Sub Timer1_Timer()
    With Picture1
        If .Left + xSpeed > x2 Then
            Timer1.Enabled = False
        Else
            .Move .Left + xSpeed, .Top + ySpeed
        End If
    End With
End Sub
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4336
Joined: 26 Apr 2010, 17:36

Re: WHO REMEMBER this old window

Post by sal21 »

HansV wrote:
25 Feb 2022, 14:52
Try this. Change xSpeed, x1, y1, x2 and y2 as you prefer.

Code: Select all

Const xSpeed As Single = 5
Dim ySpeed As Single

' Start Position
Const x1 As Single = 20, y1 As Single = 25
' End position
Const x2 As Single = 200, y2 As Single = 100

Private Sub Form_Load()
    Me.ScaleMode = vbPixels
    With Picture1
        .ScaleMode = vbPixels
        .AutoSize = True
        .BorderStyle = 0
        .BackColor = vbWhite
        .Picture = Me.Icon
        ' Set the start position
        .Left = x1
        .Top = x2
    End With
    
    With Timer1
        .Interval = 1
        .Enabled = True
    End With
    
    ySpeed = (y2 - y1) / (x2 - x1) * xSpeed
End Sub

Private Sub Timer1_Timer()
    With Picture1
        If .Left + xSpeed > x2 Then
            Timer1.Enabled = False
        Else
            .Move .Left + xSpeed, .Top + ySpeed
        End If
    End With
End Sub
I Can assign to:.Picture = Me.Icon a icon from imagelist?

Note:
the code work like a charm

User avatar
SpeakEasy
4StarLounger
Posts: 544
Joined: 27 Jun 2021, 10:46

Re: WHO REMEMBER this old window

Post by SpeakEasy »

> .Interval = 1

No real point, system clock doesn't tick that fast ...

User avatar
HansV
Administrator
Posts: 78364
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: WHO REMEMBER this old window

Post by HansV »

sal21 wrote:
25 Feb 2022, 17:13
I Can assign to:.Picture = Me.Icon a icon from imagelist?
For example:

Code: Select all

    Me.Image1.Picture = Me.ImageList1.ListImages(1).Picture
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4336
Joined: 26 Apr 2010, 17:36

Re: WHO REMEMBER this old window

Post by sal21 »

HansV wrote:
25 Feb 2022, 19:38
sal21 wrote:
25 Feb 2022, 17:13
I Can assign to:.Picture = Me.Icon a icon from imagelist?
For example:

Code: Select all

    Me.Image1.Picture = Me.ImageList1.ListImages(1).Picture
Tks bro.

User avatar
sal21
PlatinumLounger
Posts: 4336
Joined: 26 Apr 2010, 17:36

Re: WHO REMEMBER this old window

Post by sal21 »

HansV wrote:
25 Feb 2022, 19:38
sal21 wrote:
25 Feb 2022, 17:13
I Can assign to:.Picture = Me.Icon a icon from imagelist?
For example:

Code: Select all

    Me.Image1.Picture = Me.ImageList1.ListImages(1).Picture
Problem...

i need to start picture in the area of the right listview and run the animation to the left listview
I have draw in right listview the picture, but i dont see! i have set the picture also to bring to the front, but always i dont see...

peraph i need to use other picture controll?
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78364
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: WHO REMEMBER this old window

Post by HansV »

I'm sorry, I cannot help you with this. Perhaps Speakeasy will have a suggestion.
Best wishes,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4336
Joined: 26 Apr 2010, 17:36

Re: WHO REMEMBER this old window

Post by sal21 »

HansV wrote:
28 Feb 2022, 10:57
I'm sorry, I cannot help you with this. Perhaps Speakeasy will have a suggestion.
OK.
TKS

User avatar
sal21
PlatinumLounger
Posts: 4336
Joined: 26 Apr 2010, 17:36

Re: WHO REMEMBER this old window

Post by sal21 »

HansV wrote:
28 Feb 2022, 10:57
I'm sorry, I cannot help you with this. Perhaps Speakeasy will have a suggestion.
Resolved with picturebox (named me.pictlitview)

actually i need to animatuion path only in orizhontal from start postion in left listview to the and in right listview position

On mouse move cursor have start position
x= 4935 y=1320

On mouse move cursor have end position
x=4110 y=1155

the picturebox start to the default is Left=10680 Top=3480 and to end position is Left=20160 Top=3480
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 78364
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: WHO REMEMBER this old window

Post by HansV »

Just use the x-coordinate of the mouse then, and supply your own y-coordinate.
Best wishes,
Hans

User avatar
SpeakEasy
4StarLounger
Posts: 544
Joined: 27 Jun 2021, 10:46

Re: WHO REMEMBER this old window

Post by SpeakEasy »

By the way, the VB6 documentation is key here:
Three graphical layers are associated with forms and containers. The back layer is the drawing space where the results of the graphics methods are displayed. Next is the middle layer where graphical objects and Label controls are displayed. The front layer is where all nongraphical controls like CommandButton, CheckBox, or ListBox are displayed. Anything contained in a layer closer to the front covers anything contained in the layer(s) behind it
and, most importantly
ZOrder arranges objects only within the layer where the object is displayed
The image control is a graphical control and lives in the middle layer, which is always below the layer containing non-graphical controls - such as a listview.

(As you have discovered, this makes simple animation across an existing form a pain in the neck - but to be fair, I don't think easy animation of a form was a design goal of the classic VB forms engine.)

Your most recent solution works because the Picturebox is, perhaps a little confusingly, NOT a graphical control, and so sits in the front layer, and thus can be set above a listview.

Note, however, that a picturebox is not transparent, so you cannot see through it to the layers underneath, which means it will not display icons properly. This probably doesn't matter in your case.

User avatar
sal21
PlatinumLounger
Posts: 4336
Joined: 26 Apr 2010, 17:36

Re: WHO REMEMBER this old window

Post by sal21 »

HansV wrote:
28 Feb 2022, 16:00
Just use the x-coordinate of the mouse then, and supply your own y-coordinate.
my last code.

how to repeat the cycle for 3 time?

peraph with a for next? if yes where?

Code: Select all


Option Explicit
Private Sub START_ANIM()

    Me.ScaleMode = vbPixels

    With PICTLISTVIEW
        .Visible = True
        .ScaleMode = vbPixels
        '.Left = x1
    End With

    With Timer3
        .Interval = 1
        .Enabled = True
    End With

    ySpeed = (y2 - y1) / (x2 - x1) * xSpeed

End Sub
Private Sub Command1_Click()

    Call START_ANIM

End Sub
Private Sub Timer3_Timer()

    With Me.PICTLISTVIEW
        If .Left + xSpeed > x2 Then
            Timer3.Enabled = False
            .Left = x1
            .Visible = False
        Else
            .Move .Left + xSpeed, .Top + ySpeed
        End If
    End With

End Sub