How to get rid of graph flicker?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Mehrdad

    How to get rid of graph flicker?

    Hi all,

    I am programing for a user controll which is refreshing every 0.05 of a
    second. the client area is flickering. I used the below code in the
    constructor:
    --------------------------
    SetStyle(Contro lStyles.Optimiz edDoubleBuffer |
    ControlStyles.A llPaintingInWmP aint, true);
    --------------------------
    It made it so much better, but it is still flickering. Is there any other
    way to completely get rid of it?

    Thank you in advance,
    Mehrdad


  • Peter Duniho

    #2
    Re: How to get rid of graph flicker?

    On Sat, 21 Jun 2008 07:54:08 -0700, Mehrdad <galaxy@irandoc .ac.irwrote:
    I am programing for a user controll which is refreshing every 0.05 of a
    second. the client area is flickering. I used the below code in the
    constructor:
    --------------------------
    SetStyle(Contro lStyles.Optimiz edDoubleBuffer |
    ControlStyles.A llPaintingInWmP aint, true);
    --------------------------
    It made it so much better, but it is still flickering. Is there any other
    way to completely get rid of it?
    I don't understand how "it made it so much better, but it is still
    flickering". "Flickering " isn't generally a matter of degrees. It's
    caused by erasing on-screen and then drawing over the erased area
    on-screen. You can eliminate it, but to simply "reduce" it would mean
    that sometimes the control is being double-buffered and sometimes it's
    not. That seems like an unlikely scenario to me.

    Now, all that said...have you tried simply setting the DoubleBuffered
    property to "true"? I don't ever use the control styles to control
    double-buffering.

    Pete

    Comment

    • Mehrdad

      #3
      Re: How to get rid of graph flicker?

      Thank you for your answer. Yes, I set the double buffering to true. I think
      when the OnPaint methode is triggering, it clears the client area before
      fetching the buffered information into it. Is it true? If yes, how can I
      prevent it to clear?

      Thanks again,
      Mehrdad



      "Peter Duniho" <NpOeStPeAdM@nn owslpianmk.comw rote in message
      news:op.uc3y4fw q8jd0ej@petes-computer.local. ..
      On Sat, 21 Jun 2008 07:54:08 -0700, Mehrdad <galaxy@irandoc .ac.irwrote:
      >
      >I am programing for a user controll which is refreshing every 0.05 of a
      >second. the client area is flickering. I used the below code in the
      >constructor:
      >--------------------------
      >SetStyle(Contr olStyles.Optimi zedDoubleBuffer |
      >ControlStyles. AllPaintingInWm Paint, true);
      >--------------------------
      >It made it so much better, but it is still flickering. Is there any other
      >way to completely get rid of it?
      >
      I don't understand how "it made it so much better, but it is still
      flickering". "Flickering " isn't generally a matter of degrees. It's
      caused by erasing on-screen and then drawing over the erased area
      on-screen. You can eliminate it, but to simply "reduce" it would mean
      that sometimes the control is being double-buffered and sometimes it's
      not. That seems like an unlikely scenario to me.
      >
      Now, all that said...have you tried simply setting the DoubleBuffered
      property to "true"? I don't ever use the control styles to control
      double-buffering.
      >
      Pete

      Comment

      • Chris Jobson

        #4
        Re: How to get rid of graph flicker?

        Thank you for your answer. Yes, I set the double buffering to true. I
        think when the OnPaint methode is triggering, it clears the client area
        before fetching the buffered information into it. Is it true? If yes, how
        can I prevent it to clear?
        I'm not sure about this, but I seem to remember something about overriding
        OnPaintBackgrou nd with a method that does nothing.

        Chris Jobson


        Comment

        • Peter Duniho

          #5
          Re: How to get rid of graph flicker?

          On Sun, 22 Jun 2008 02:05:53 -0700, Mehrdad <galaxy@irandoc .ac.irwrote:
          Thank you for your answer. Yes, I set the double buffering to true.
          That statement is ambiguous. "set the double buffering to true" could
          mean anything. As opposed to "Set the Control.DoubleB uffered property to
          true", which is very specific. So what did you actually do?
          I think
          when the OnPaint methode is triggering, it clears the client area before
          fetching the buffered information into it. Is it true? If yes, how can I
          prevent it to clear?
          If you set the DoubleBuffered property to true, then even though the
          background is cleared before OnPaint() is called, it's cleared in the
          back-buffer, not on-screen. There should be no flickering.

          On the other hand, if you use some other technique to try to enable
          double-buffering (such as the code you posted), then you are responsible
          for handling all of the double-buffering. This includes not erasing the
          on-screen image (which is what Chris is talking about) and making sure
          that you paint the entire control in the OnPaint() method, and do it all
          at once (i.e. draw into your own back buffer and then copy that to the
          screen Graphics instance provided in the PaintEventArgs) .

          Pete

          Comment

          • Mehrdad

            #6
            Re: How to get rid of graph flicker?

            Thank you very much,

            Actually, as a part of a project, I am creating a histogram component which
            its graphs should be as soft as possible.

            Thank you for your complete answer :)
            Mehrdad

            "Peter Duniho" <NpOeStPeAdM@nn owslpianmk.comw rote in message
            news:op.uc5umpt l8jd0ej@petes-computer.local. ..
            On Sun, 22 Jun 2008 02:05:53 -0700, Mehrdad <galaxy@irandoc .ac.irwrote:
            >
            >Thank you for your answer. Yes, I set the double buffering to true.
            >
            That statement is ambiguous. "set the double buffering to true" could
            mean anything. As opposed to "Set the Control.DoubleB uffered property to
            true", which is very specific. So what did you actually do?
            >
            >I think
            >when the OnPaint methode is triggering, it clears the client area before
            >fetching the buffered information into it. Is it true? If yes, how can I
            >prevent it to clear?
            >
            If you set the DoubleBuffered property to true, then even though the
            background is cleared before OnPaint() is called, it's cleared in the
            back-buffer, not on-screen. There should be no flickering.
            >
            On the other hand, if you use some other technique to try to enable
            double-buffering (such as the code you posted), then you are responsible
            for handling all of the double-buffering. This includes not erasing the
            on-screen image (which is what Chris is talking about) and making sure
            that you paint the entire control in the OnPaint() method, and do it all
            at once (i.e. draw into your own back buffer and then copy that to the
            screen Graphics instance provided in the PaintEventArgs) .
            >
            Pete

            Comment

            Working...