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

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);
 
N

Nicholas Paldino [.NET/C# MVP]

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?
 
A

Andy Chen

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);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top