/// <summary> /// Called when helped form is activated /// </summary> /// <param name="sender">Object that raised the event</param> /// <param name="e">Event data</param> protected virtual void Form_Load(object sender, EventArgs e) { if (DesignMode) { return; } WinApi.MARGINS dwmMargins = new WinApi.MARGINS( Margins.Left, Margins.Right, Margins.Bottom + ((Ribbon.OrbStyle == RibbonOrbStyle.Office_2007) ? Ribbon.CaptionBarHeight : Ribbon.CaptionBarHeight + Ribbon.TabsMargin.Top), Margins.Bottom); if (WinApi.IsTen && !_frameExtended) { dwmMargins.cxLeftWidth -= 6; dwmMargins.cxRightWidth -= 7; dwmMargins.cyTopHeight -= 2; dwmMargins.cyBottomHeight -= 8; WinApi.DwmExtendFrameIntoClientArea(Form.Handle, ref dwmMargins); _frameExtended = true; //dwmMargins.cxRightWidth += 7; //// https://msdn.microsoft.com/en-us/library/windows/desktop/aa969512(v=vs.85).aspx } else if (WinApi.IsVista && !_frameExtended) { WinApi.DwmExtendFrameIntoClientArea(Form.Handle, ref dwmMargins); _frameExtended = true; } }
public void Start() { #if !UNITY_EDITOR // You really don't want to enable this in the editor.. bool dmwEnabled; NativeMethods.DwmIsCompositionEnabled(out dmwEnabled); var hwnd = NativeMethods.GetActiveWindow(); if (dmwEnabled) { int fWidth = Screen.width; int fHeight = Screen.height; var margins = new WinApi.MARGINS { cxLeftWidth = -1 }; // Transparent windows with click through NativeMethods.SetWindowLong(hwnd, WinApi.GWL_EXSTYLE, WinApi.WS_EX_LAYERED | WinApi.WS_EX_TRANSPARENT); NativeMethods.SetLayeredWindowAttributes(hwnd, 0, 255, WinApi.LWA_ALPHA); NativeMethods.SetWindowPos(hwnd, WinApi.HWND_TOPMOST, 0, 0, fWidth, fHeight, WinApi.SWP_FRAMECHANGED | WinApi.SWP_SHOWWINDOW); NativeMethods.DwmExtendFrameIntoClientArea(hwnd, ref margins); } else { NativeMethods.MessageBoxW(hwnd, "You must have an Aero compatible theme enabled.", "Error", WinApi.MESSAGEBOXTYPE_OK); Application.Quit(); } #endif }
protected override void WndProc(ref Message m) { if (m.Msg == WmNcpaint && _mAeroEnabled) { var v = 2; WinApi.DwmSetWindowAttribute(Handle, 2, ref v, 4); var margins = new WinApi.MARGINS(1, 1, 1, 1); WinApi.DwmExtendFrameIntoClientArea(Handle, ref margins); } base.WndProc(ref m); if (m.Msg == WmNchittest && (int)m.Result == Htclient) // drag the form { m.Result = (IntPtr)Htcaption; } }
/// <summary> /// Called when helped form is activated /// </summary> /// <param name="sender">Object that raised the event</param> /// <param name="e">Event data</param> protected virtual void Form_Activated(object sender, EventArgs e) { if (DesignMode) { return; } WinApi.MARGINS dwmMargins = new WinApi.MARGINS( Margins.Left, Margins.Right, Margins.Bottom + Ribbon.CaptionBarHeight, Margins.Bottom); if (WinApi.IsVista && !_frameExtended) { WinApi.DwmExtendFrameIntoClientArea(Form.Handle, ref dwmMargins); _frameExtended = true; } }
/// <summary> /// Called when helped form is activated /// </summary> /// <param name="sender">Object that raised the event</param> /// <param name="e">Event data</param> protected virtual void Form_Load(object sender, EventArgs e) { if (DesignMode) { return; } WinApi.MARGINS dwmMargins = new WinApi.MARGINS( Margins.Left, Margins.Right, Margins.Bottom + ((Ribbon.OrbStyle == RibbonOrbStyle.Office_2007) ? Ribbon.CaptionBarHeight : Ribbon.CaptionBarHeight + Ribbon.TabsMargin.Top), Margins.Bottom); if (WinApi.IsVista && !_frameExtended) { WinApi.DwmExtendFrameIntoClientArea(Form.Handle, ref dwmMargins); _frameExtended = true; } }
protected override void WndProc(ref Message m) { if (DesignMode) { base.WndProc(ref m); return; } base.WndProc(ref m); switch (m.Msg) { case (int)WinApi.Messages.WM_NCPAINT: // Allow to display the shadows if (_mAeroEnabled) { var v = 2; WinApi.DwmSetWindowAttribute(Handle, 2, ref v, 4); var margins = new WinApi.MARGINS(1, 1, 1, 1); WinApi.DwmExtendFrameIntoClientArea(Handle, ref margins); } break; } }
protected override void WndProc(ref Message m) { if (m.Msg == WmNcpaint && _mAeroEnabled) { var v = 2; WinApi.DwmSetWindowAttribute(Handle, 2, ref v, 4); var margins = new WinApi.MARGINS(1, 1, 1, 1); WinApi.DwmExtendFrameIntoClientArea(Handle, ref margins); } base.WndProc(ref m); if (m.Msg == WmNchittest && (int)m.Result == Htclient) // drag the form m.Result = (IntPtr)Htcaption; }
private void ExtendGlass() { if (!WinApi.IsGlassEnabled) return; WinApi.MARGINS m = new WinApi.MARGINS(); m.cyTopHeight = 0; m.cxLeftWidth = 0; m.cxRightWidth = 0; m.cyBottomHeight = 1; WinApi.DwmExtendFrameIntoClientArea(this.Handle, ref m); }