WebBrowser control flicker on modal window during resize.

  • Thread starter Thread starter Rina
  • Start date Start date
R

Rina

When WebBrowser is on modal form it flickers heavily during resize.
Works fine on non modal form.

This is simple snippet that reproduces problem.

Please make sure that display property "Display properties->
Appearance -> Effects-> Show Window contents wile dragging" is
checked.

Run the program.
Press "ShowDialog button". A modal form with WebBrowser is opened.
Resize the form. See it flickers.
Press "Show button". A form with WebBrowser is opened. Resize the
form. See it works fine.

Any ides how to prevent this flickering ?


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace BrowserFlickerss
{
public class Form1 : Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
public Form1()
{
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.SuspendLayout();
//
// button1
//
this.button1.Bounds = new Rectangle(54, 45, 75, 23);
this.button1.Name = "button1";
this.button1.Text = "Show";
this.button1.Click += new System.EventHandler
(this.button1_Click);
//
// button2
//
this.button2.Bounds = new Rectangle(54, 120, 75, 23);
this.button2.Name = "button2";
this.button2.Text = "ShowDialog";
this.button2.Click += new System.EventHandler
(this.button2_Click);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Text = "Form1";
this.ResumeLayout(false);
}



private void button1_Click(object sender, EventArgs e)
{
Form form = new Form2();
form.Show();

}

private void button2_Click(object sender, EventArgs e)
{
Form form = new Form2();
form.ShowDialog();
form.Dispose();

}

[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}

}


public class Form2 : Form
{
private System.Windows.Forms.WebBrowser webBrowser1;
public Form2()
{
this.webBrowser1 = new System.Windows.Forms.WebBrowser();
this.SuspendLayout();
//
// webBrowser1
//
this.webBrowser1.Dock = System.Windows.Forms.DockStyle.Fill;
this.webBrowser1.Location = new System.Drawing.Point(0, 0);
this.webBrowser1.Name = "webBrowser1";
this.webBrowser1.Size = new System.Drawing.Size(292, 266);
//
// Form2
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(292, 266);
this.Controls.Add(this.webBrowser1);
this.Name = "Form2";
this.Text = "Form2";
this.ResumeLayout(false);
webBrowser1.Navigate("http://www.google.com/");
}


}


}
 
Back
Top