"FillRectangle" draws with a different color when DoubleBuffered

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • phommy
    New Member
    • Mar 2010
    • 4

    "FillRectangle" draws with a different color when DoubleBuffered

    please test this:

    Code:
            public Form1()
            {
                InitializeComponent();
                this.DoubleBuffered = true;
            }
    
            protected override void OnPaint(PaintEventArgs e)
            {
                e.Graphics.FillRectangle(new SolidBrush(BackColor), 0, 0, 50, 50);
                base.OnPaint(e);
            }
    The color it draw with is not SystemColor.Bac kColor but a different one. I don't know if it's by design or a bug. Can I do something to FillRectangle with pure color when double-buffered?

    thank you!

    If the image below is absent, please see this
    Attached Files
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    'Backcolor' is a property of your form. You can set the Backcolor of your form to anything you like.

    Try looking at your available choices..

    Start typing Color bob = Color.FromKnown Color(KnownColo r.
    {Intellisense will popup here giving you a list}

    To the best of my knowledge there is no such color designation as System.Backcolo r

    Comment

    • phommy
      New Member
      • Mar 2010
      • 4

      #3
      I'm sorry to say that's a foolish question. I found there's no business with "DoubleBuff er".
      Under 16-bit color the backcolor of control is "GetNearestColo r"ed when drawn by system, so the color is different with
      Code:
      e.Graphics.FillRectangle(new SolidBrush(BackColor)
      thank you all the same

      Comment

      Working...