chris jones

chris jones

  • NA
  • 5
  • 0

onpaint WebBrowser control can not be overiddren

Dec 15 2006 9:54 AM

I just playing with the WebBrowser control, I want a long green line drawn across the page.


My code is below but the onPaint method neaver gets called, in the document the method are not set to final.

public
class MyNewWebBrowser: System.Windows.Forms.WebBrowser{

public MyNewWebBrowser(){
SetStyle(ControlStyles.UserPaint, true);
}

protected override void OnPaint(PaintEventArgs e){
Graphics g = e.Graphics;

// Create a new Pen object.
Pen greenPen = new Pen(Color.Green);

// Set the width to 6.
greenPen.Width = 6.0F;

// Set the DashCap to round.
greenPen.DashCap = System.Drawing.Drawing2D.DashCap.Round;

// Create a custom dash pattern.

greenPen.DashPattern = new float[] { 4.0F, 2.0F, 1.0F, 3.0F };

// Draw a line.

g.DrawLine(greenPen, 20.0F, 20.0F, 100.0F, 240.0F);

// Change the SmoothingMode to none.

g.SmoothingMode =

System.Drawing.Drawing2D.SmoothingMode.None;

// Draw another line.

g.DrawLine(greenPen, 100.0F, 240.0F, 160.0F, 20.0F);

// Dispose of the custom pen.

greenPen.Dispose();

}

}

}