Results 1 to 22 of 22

Thread: timer and mousemove problems

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2009
    Location
    Australia
    Posts
    130

    Resolved timer and mousemove problems

    Hi folks.

    I am creating a screensaver app, using a timer to display a different picture every 10 seconds.

    1. Why does my code result in an initial blank picturebox displayed for 10 seconds, and then the other pics are displayed after? I don't understand why the blank picturebox is displayed.

    2. I want the form to close when the mouse is moved(the screensaver to stop running), so I set the mousemove event to close the form, but when I move the mouse, the form doesn't close. Why?

    Thanks in advance.

    Code:
    Public Class Form1
    
        Private Sub Form1_Load(sender As Object, e As System.EventArgs) Handles Me.Load
            Timer1.Start()
        End Sub
    
        Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
            Static ctr As Integer = 0
            Dim pics() As Image = {My.Resources._1, My.Resources._2, My.Resources._3, My.Resources._4, My.Resources._5, My.Resources._6}
    
            PictureBox1.Image = pics(ctr)
            ctr = ctr + 1
            If ctr > 5 Then
                ctr = 0
            End If
        End Sub
    
        Private Sub PictureBox1_Click(sender As Object, e As System.EventArgs) Handles PictureBox1.Click
            Me.Close()
        End Sub
    
        Private Sub Form1_MouseMove(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
            Me.Close()
        End Sub
    End Class
    Last edited by vbforever23; May 9th, 2013 at 07:08 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width