protected override void WndProc(ref Message m) { base.WndProc(ref m); if (m.Msg == NativeMethods.WM_PAINT && this.IsHandleCreated == true) { if (this.Enabled == false || string.IsNullOrEmpty(this.Text) && !string.IsNullOrEmpty(this.LabelText) && this.Focused == false) { Graphics g = m.HWnd != IntPtr.Zero ? Graphics.FromHwnd(m.HWnd) : null; if (g != null) { DrawingUtils.FillRectangle(g, this.BackColor, this.ClientRectangle); TextRenderer.DrawText( g, this.Enabled == true ? this.LabelText : this.Text, this.Font, this.ClientRectangle, this.DisabledTextColor, this.textFormat); } } } }
protected override void OnPaintBackground(PaintEventArgs pevent) { DrawingUtils.FillRectangle(pevent.Graphics, this.BackColor, pevent.ClipRectangle); }