How to draw a rectangle on AxWebBrowser to high light one html element?

  • Thread starter Thread starter Andy Chen
  • Start date Start date
A

Andy Chen

Hi,

Now I can get the rectangle to draw, but it seems the rectangle is not
visible. The following code is used to draw the rectangle. Hope someone can
help. Thanks very much!

SolidBrush brush = new
System.Drawing.SolidBrush(System.Drawing.Color.Red);
Pen pen = new Pen(brush, 4);
Graphics formGraphics = Graphics.FromHwnd(this.axWebBrowser.Handle);
formGraphics.DrawRectangle(pen, rect);
 
Andy,

Why don't you change the markup so that the rectangle is drawn by the
control itself, instead of drawing on the control itself?
 
Yes, actually I tried by overriding the Wndproc method and handle WM_PAINT
message. Unfortunately I failed. Is there any interfaces provided by
webbrowser control can be used to do this job?

Thanks!
Andy

Nicholas Paldino said:
Andy,

Why don't you change the markup so that the rectangle is drawn by the
control itself, instead of drawing on the control itself?


--
- Nicholas Paldino [.NET/C# MVP]
- (e-mail address removed)

Andy Chen said:
Hi,

Now I can get the rectangle to draw, but it seems the rectangle is not
visible. The following code is used to draw the rectangle. Hope someone
can help. Thanks very much!

SolidBrush brush = new
System.Drawing.SolidBrush(System.Drawing.Color.Red);
Pen pen = new Pen(brush, 4);
Graphics formGraphics = Graphics.FromHwnd(this.axWebBrowser.Handle);
formGraphics.DrawRectangle(pen, rect);
 
Back
Top