//protected override CreateParams CreateParams //{ // get // { // CreateParams cp = base.CreateParams; // cp.ExStyle |= 0x80000; // return base.CreateParams; // } //} public TransparentForm() { InitializeComponent(); if (Environment.OSVersion.Version.Major >= 6 && !this.DesignMode) { this.isBlurEnabled = DWMNativeMethods.IsCompositionEnable(); } }
protected override void OnPaintBackground(PaintEventArgs pevent) { if (DWMNativeMethods.IsCompositionEnable()) { pevent.Graphics.Clear(Color.Black); } else { base.OnPaintBackground(pevent); } }
protected override void OnPaint(System.Windows.Forms.PaintEventArgs pevent) { if (DWMNativeMethods.IsCompositionEnable()) { Rectangle clientRectangle = new Rectangle(0, 0, this.Width, this.Height); ButtonRenderer.DrawParentBackground(pevent.Graphics, this.Bounds, this.Parent); ButtonRenderer.DrawButton(pevent.Graphics, clientRectangle, this.buttonState); //Image imgText = AdvanceDrawing.DrawBlurryText(this.Text, this.Font, this.ForeColor, this.BackColor, 1); //Point ptText = new Point((this.Width - imgText.Width) / 2, (this.Height - imgText.Height) / 2); //pevent.Graphics.DrawImageUnscaled(imgText, ptText); //imgText.Dispose(); Rectangle rect = this.ClientRectangle; rect.Inflate(-Margin.Horizontal, -Margin.Vertical); //rect.Offset(-Margin.Left, -Margin.Top); if (this.Enabled) { AdvanceDrawing.DrawTextAndImage( pevent.Graphics, rect, this.Text, this.Font, this.ForeColor, this.BackColor, this.TextAlign, this.Image, this.ImageAlign); } else { AdvanceDrawing.DrawDisabledTextAndImage( pevent.Graphics, rect, this.Text, this.Font, this.ForeColor, this.BackColor, this.TextAlign, this.Image, this.ImageAlign); } } else { base.OnPaint(pevent); } }