1

The following picture represents a panel over a WebBrowser control in c#.

enter image description here

However, if i put the panels background property to 'transparent', it will show the color 'Silver' as my form's background is silver.

My question is; how can I draw a overlay over my custom WebBrowser control so that when it is 'transparent', it will show the WebBrowser control instead of the form's background color.

Thanks.

Andrew
  • 552
  • 2
  • 10
  • 29
  • You cannot make this work. You'll need to overlay it with another window. A borderless owned form that has its TransparencyKey set, similar [to this](http://stackoverflow.com/a/4503371/17034) – Hans Passant Apr 25 '13 at 03:00
  • I was afraid it was going to come down to this answer. My only question is the following; how can I make the 2nd borderless form stay in the top left corner such as what the picture shows. – Andrew Apr 25 '13 at 04:34
  • Use the LocationChanged event. – Hans Passant Apr 25 '13 at 05:09

1 Answers1

1

I believe it comes down to the OnPaint methods of panels.

Where there are multiple controls overlapping each other only the top control is drawn for that area of the screen. By making the control transparent, you are making that area of the screen the forms background colour

I believe this question has some suggestions on solutions; this question seems to point towards the OnPaintBackground more specifically also

Question link

Community
  • 1
  • 1
Sayse
  • 42,633
  • 14
  • 77
  • 146