Using event to switch between photos
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1

Thread: Using event to switch between photos

Hybrid View

  1. #1
    Join Date
    Dec 2012
    Posts
    1

    Using event to switch between photos

    Hello,

    I have 2 forms with 2 pictureBoxs, showing photos.

    In the forms there is timer set to 10Sec.

    In those 10Sec, the viewer can Key press for an answer.

    Right after key press, I would like to switch between the forms (no regarding to the remaining time), and restart the timer..

    How can I do that?

    I've created timer1, timer2 in Form1, Here is the code in Form1:
    Code:
        private void timer1_Tick(object sender, EventArgs e)
                {
                    if (!stopSlideshow)
                    {
                        timer1.Stop();
                        timer2.Start();
                        form2.Show();
                        form2.startTimer();
                        this.Hide();
                    }
                }
       
                private void timer2_Tick_1(object sender, EventArgs e)
                {
                    if (!stopSlideshow)
                    {
                            pictureBox1.Image = getPicture();
                            timer2.Stop();
                            timer1.Start();
                    }
                }
    And timer1 in form 2, Here is the code in Form2:
    Code:
         public void startTimer()
                {
                    timer1.Start();           
                }
       
                private void timer1_Tick_1(object sender, EventArgs e)
                {
                    timer1.Stop();
                    this.Hide();
                    Form1.F1.Show(); 
                }
    Tick Event is timer1_Tick_1.

    I already used the "Keydown" event to save the viewer's answer.

    Thanks!
    Last edited by DataMiser; December 18th, 2012 at 10:44 AM. Reason: added code tags for readability

Posting Permissions

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


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center