Link to home
Start Free TrialLog in
Avatar of guyvaio
guyvaio

asked on

DWM problem (Vista glass) when setting transparencykey

Please consider the minimum code below. This code creates a simple form with a 100 pixels above margin with vista blur glass effect. (For support purpose, we assume this code will be only executed under Vista)

All works very fine until I set the transparencyKey of this form. If the transparencyKey is set to a non empty value, the blur glass region is painted in black.

My pupose is to "bore a hole" in the form to let see a region of the next application in the z-order.

Thanks in advance for help,

Kind regards,

Guy
public partial class Form1 : Form
    {
        MARGINS glassMarges;
 
        public Form1()
        {
            InitializeComponent();
            glassMarges = new MARGINS(0, 0, 100, 0);
            DwmExtendFrameIntoClientArea(this.Handle, ref glassMarges);
            this.Invalidate();  
        }
 
        protected override void OnPaint(PaintEventArgs e)
        {
            e.Graphics.FillRectangle(Brushes.Black, Rectangle.FromLTRB(0, 0,this.ClientRectangle.Width, glassMarges.cyTopHeight));
            base.OnPaint(e);
        }
 
 
        [DllImport("dwmapi.dll", PreserveSig = false)]
        public static extern void DwmExtendFrameIntoClientArea(IntPtr hWnd, ref MARGINS pMargins);
        
        [StructLayout(LayoutKind.Sequential)]
        public struct MARGINS
        {
            public int cxLeftWidth, cxRightWidth, cyTopHeight, cyBottomHeight;
 
            public MARGINS(int left, int right, int top, int bottom)
            {
                cxLeftWidth = left; cyTopHeight = top;
                cxRightWidth = right; cyBottomHeight = bottom;
            }
        }
 
    }

Open in new window

Avatar of guyvaio
guyvaio

ASKER

No answer. Does it mean "no solution" ?
Is really possible that Microsoft has conceived as "incompatible" the transparency and the blur effect in the .net framework ?
Kind regrads,
Guy
ASKER CERTIFIED SOLUTION
Avatar of guyvaio
guyvaio

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial