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 Answer 1

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.

6
  • Doesn't work sorry. I might be doing something screwy of course, so I'll keep looking but looks like a no go.
    – Sam Barham
    Aug 3, 2009 at 1: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: hiveminds.co.uk/?p=3225&cpage=1
    – SpliFF
    Aug 3, 2009 at 1: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 3, 2009 at 7:33
  • oh, and paste the relevant bits of source code, there may be an issue there.
    – SpliFF
    Aug 3, 2009 at 7: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.
    – Sam Barham
    Aug 3, 2009 at 22:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.