none
this.Refresh(); problem in C#

    Question

  • hi there.

     

    i am developing a windows application in C#.

    i am facing the form controls lock problem. when we fill images in picture box by loop.

    like that

     

    for (var1 = 0; var1 < this.trackBar1.Maximum; var1 = var1 + 10)

    {


    this.Refresh();


    this.pictureBox1.Refresh();

     


    this.pictureBox1.Image = FrameGrabber.GetFrameFromVideo(this.textBox1.Text, (var1) / this.trackBar1.Maximum);

    }


    thanks in advance

    dhemittal@gmail.com

     

    Friday, November 14, 2008 11:05 AM

Answers

  • Hi Dheeraj mittal,

     

    I guess you were using the third party Dlls to get frame from the video files, and displayed the returned bitmaps in the PictureBox contro. Actually, I didn’t reproduce your problems which you said controls locked. However, with your code, only one picture can be seen even you use a “for statement”.

     

    Please try the following changed code. Assume you have set the Maximum property of the TrackBar control to 100.

    Code Snippet

                    for (var1 = 0; var1 < this.trackBar1.Maximum; var1+=10)

                    {

                        Bitmap image = FrameGrabber.GetFrameFromVideo(this.openFileDialog1.FileName, (double)var1/this.trackBar1.Maximum);

                        this.pictureBox1.Image = image;

                        this.Refresh();

                    }

     

     

    Best regards,

    Bruce Zhou

     

    Monday, November 17, 2008 10:34 AM