Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I managed to get it working. That dark gray area I was talking about, which gets painted over everything was occuring in the OnPaint method of the form. Obviously when there is an MdiContainer present the form is preprogrammed to paint the dark gray area which was obstructing the glass. </p> <p>So just override the OnPaint method without calling it's base and then take the code that was used to draw the glass in the normal Paint method and stick it in the OnPaint method.</p> <pre><code>protected override void OnPaint(PaintEventArgs e) { //base.OnPaint(e); bool glassEnabled = IsGlassEnabled(); if (glassEnabled) // draw glass if enabled { Rectangle rc = picPlaceHolder.ClientRectangle; IntPtr destdc = e.Graphics.GetHdc(); // hwnd must be the handle of form, not control IntPtr Memdc = CreateCompatibleDC(destdc); IntPtr bitmapOld = IntPtr.Zero; BITMAPINFO dib = new BITMAPINFO(); dib.bmiHeader.biHeight = -(rc.Bottom - rc.Top); dib.bmiHeader.biWidth = rc.Right - rc.Left; dib.bmiHeader.biPlanes = 1; dib.bmiHeader.biSize = Marshal.SizeOf(typeof(BITMAPINFOHEADER)); dib.bmiHeader.biBitCount = 32; dib.bmiHeader.biCompression = BI_RGB; if (!(SaveDC(Memdc) == 0)) { IntPtr bitmap = CreateDIBSection(Memdc, ref dib, DIB_RGB_COLORS, 0, IntPtr.Zero, 0); if (!(bitmap == IntPtr.Zero)) { bitmapOld = SelectObject(Memdc, bitmap); BitBlt(destdc, rc.Left, rc.Top, rc.Right - rc.Left, rc.Bottom - rc.Top, Memdc, 0, 0, SRCCOPY); } // remember to clean up SelectObject(Memdc, bitmapOld); DeleteObject(bitmap); ReleaseDC(Memdc, -1); DeleteDC(Memdc); } e.Graphics.ReleaseHdc(); } } </code></pre> <p>Then just ensure that the MdiContainer is not in the way of the glass and it should draw perfectly.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload