/// <summary> /// Sets the value of AeroEnabled /// </summary> private void CheckGlassEnabled() { if (Environment.OSVersion.Version.Major >= 6) { int enabled = 0; int response = Dwm.DwmIsCompositionEnabled(ref enabled); _aeroEnabled = enabled == 1; } }
protected override void OnActivated(EventArgs e) { base.OnActivated(e); if (dwmMargins.cyTopHeight < tsNonClientToolStrip.Bottom) { dwmMargins.cyTopHeight = tsNonClientToolStrip.Bottom; } Dwm.DwmExtendFrameIntoClientArea(this.Handle, ref dwmMargins); }
protected override void WndProc(ref Message m) { int WM_NCCALCSIZE = 0x83; int WM_NCHITTEST = 0x84; IntPtr result; int dwmHandled = Dwm.DwmDefWindowProc(m.HWnd, m.Msg, m.WParam, m.LParam, out result); if (dwmHandled == 1) { m.Result = result; return; } if (m.Msg == WM_NCCALCSIZE && (int)m.WParam == 1) { NCCALCSIZE_PARAMS nccsp = (NCCALCSIZE_PARAMS)Marshal.PtrToStructure(m.LParam, typeof(NCCALCSIZE_PARAMS)); // Adjust (shrink) the client rectangle to accommodate the border: nccsp.rect0.Top += 0; nccsp.rect0.Bottom += 0; nccsp.rect0.Left += 0; nccsp.rect0.Right += 0; if (!_marginOk) { //Set what client area would be for passing to DwmExtendIntoClientArea dwmMargins.cyTopHeight = nccsp.rect2.Top - nccsp.rect1.Top; dwmMargins.cxLeftWidth = nccsp.rect2.Left - nccsp.rect1.Left; dwmMargins.cyBottomHeight = nccsp.rect1.Bottom - nccsp.rect2.Bottom; dwmMargins.cxRightWidth = nccsp.rect1.Right - nccsp.rect2.Right; _marginOk = true; } Marshal.StructureToPtr(nccsp, m.LParam, false); m.Result = IntPtr.Zero; } else if (m.Msg == WM_NCHITTEST && (int)m.Result == 0) { m.Result = HitTestNCA(m.HWnd, m.WParam, m.LParam); } else { base.WndProc(ref m); } }