views:

160

answers:

1

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?

A: 

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
Doesn't work sorry. I might be doing something screwy of course, so I'll keep looking but looks like a no go.
SpliFF
Still can't get it to work sorry
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
oh, and paste the relevant bits of source code, there may be an issue there.
SpliFF
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 weird2) 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.
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.
Got it working at last. Yay! Thank you!