0

I have a bunch of controls derived from System.Windows.Forms.UserControl, which are then being displayed in a browser (Internet Explorer only). The page they are in has a border (a div) that I want the controls to go 'under', but they all draw on top of it.

I've seen pages claiming that what I need to do is make the UserControls 'windowless', and examples of how to do it in VisualBasic or in SilverLight, but nothing helpful for me (I'm using C++ and C# here)

So, any ideas?

1 Answers1

0

There was a trick that used to be common for putting divs over native elements in IE. You put a transparent iframe with nothing in it under the div you're trying to raise;

<!-- windows forms garbage here -->

<iframe id="underlay" src="javascript:false" frameborder="0" style="Alpha(style=0,opacity=0)"></iframe>
<div id="overlay"></div>

This would push overlay into a new directx layer (not to be confused with browser layer, ie z-index).

EDIT: Found why it didn't work: "The other technique, which uses the IFRAME element's ALLOWTRANSPARENCY attribute, actually pertains to making the interior page background of the IFRAME transparent, so that any content inside the IFRAME can have transparency. However, this mode changes the nature of the IFRAME and it no longer serves our purpose for blocking out windowed controls."

The fix is to use an alpha filter for the transparency effect instead of ALLOWTRANSPARENCY.

SpliFF
  • 38,186
  • 16
  • 91
  • 120
  • Doesn't work sorry. I might be doing something screwy of course, so I'll keep looking but looks like a no go. –  Aug 03 '09 at 01:55
  • I may have missed something. I think you need to ensure the iframe covers the same area as the div. This page has more detail: http://www.hiveminds.co.uk/?p=3225&cpage=1 – SpliFF Aug 03 '09 at 01:59
  • try giving the iframe a real src pointing to an actual document and see if that appears above the controls. If not try messing with its z-index. Make sure the iframe shim really covers all of the area under the div. It may also be that this trick fails in IE7, but i've used it in ie6 in the past and it worked. – SpliFF Aug 03 '09 at 07:33
  • oh, and paste the relevant bits of source code, there may be an issue there. – SpliFF Aug 03 '09 at 07:34
  • OK, I have got this kinda working, but it's still broken. There are two problems: 1) The div I want to be over the UserControl is partially transparent. The areas where it is transparent, the UserControl isn't rendered, which looks weird 2) The UserControls are on a scrollable div, and as soon as I scroll it, the UserControls pop to the front. Both things that I forgot to mention initially, sorry. –  Aug 03 '09 at 22:48
  • Also, I've found at least a few references to the problem your code fixes being fixed in IE7, so I'm guessing that my issue is something different. Thanks anyway. –  Aug 03 '09 at 23:25