protected override void OnPaintBackground(PaintEventArgs e) { if (!DwmAPI.DwmIsCompositionEnabled() || DesignMode) { base.OnPaintBackground(e); } }
public IntPtr PreviewWindowMessage(IntPtr hWindow, int message, IntPtr wParam, IntPtr lParam, ref bool handled) { switch (message) { case WM_COMPOSITIONCHANGED: this.NotifyCompositionChanged(); return(IntPtr.Zero); case WM_NCCALCSIZE: if (this.firstTimeNonClientCalc) { // Suppress first time, otherwise glass effect will be messed up.. this.firstTimeNonClientCalc = false; return(IntPtr.Zero); } else { if (this.nonClientAreaDrawingEnabled && wParam != IntPtr.Zero) //TRUE { //no nonclient frame handled = true; return(IntPtr.Zero); } else { return(IntPtr.Zero); } } case WM_NCHITTEST: IntPtr Result = IntPtr.Zero; if (this.dwmIsCompositionEnabled) { handled = DwmAPI.DwmDefWindowProc(hWindow, message, wParam, lParam, out Result); } if (handled == false) { uint Coordinates; checked { Coordinates = (uint)lParam.ToInt32(); } NonClientArea NonClientArea = this.nonClientHitTest(Coordinates.GetLoUShort(), Coordinates.GetHiUShort()); if (NonClientArea != NonClientArea.HTNOWHERE) { Result = new IntPtr((int)NonClientArea); handled = true; } } return(Result); default: return(IntPtr.Zero); } }
protected override void OnPaint(PaintEventArgs e) { if (DwmAPI.DwmIsCompositionEnabled() && !DesignMode) { UXTheme.DrawText(e.Graphics, Text, this.Font, ClientRectangle, ForeColor, TextAlignToFormatFlags(TextAlign) | TextFormatFlags.NoClipping, UXTheme.TextStyle.Glowing); } else { base.OnPaint(e); } }
internal GlassWindowHelper(IntPtr windowHandle, DwmAPI.Margins margins, bool blurClientArea, bool nonClientAreaDrawingEnabled, Action notifyDwmCompositionChanged, Func <ushort, ushort, NonClientArea> nonClientHitTest) { this.windowHandle = windowHandle; this.dwmIsCompositionEnabled = DwmAPI.IsCompositionEnabled(); this.margins = margins; this.blurClientArea = blurClientArea; this.notifyDwmCompositionChanged = notifyDwmCompositionChanged; this.UpdateGlassEffect(); this.UpdateNonClientArea(); this.nonClientAreaDrawingEnabled = nonClientAreaDrawingEnabled; this.nonClientHitTest = nonClientHitTest; this.UpdateNonClientArea(); }
protected void NotifyCompositionChanged() { this.dwmIsCompositionEnabled = DwmAPI.IsCompositionEnabled(); this.UpdateGlassEffect(); this.notifyDwmCompositionChanged(); }
private void UpdateGlassEffect() { DwmAPI.EnableGlassEffect(this.windowHandle, this.margins); DwmAPI.EnableBlurBehindWindow(this.windowHandle, this.blurClientArea); }
private void UpdateNonClientArea() { DwmAPI.SetWindowPos(this.windowHandle, IntPtr.Zero, 0, 0, 0, 0, 0x27 /*SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_FRAMECHANGED*/); }