Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Double buffering

Double buffering

Scheduled Pinned Locked Moved C#
questiondatabasecomgraphicshelp
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    S O S
    wrote on last edited by
    #1

    Form an article, I read that this enables double buffering on a form: SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.UserPaint, true); Well I tried it, using this code on an MDI child: Graphics g = CreateGraphics(); g.FillRectangle(new SolidBrush(somecolour), 0, 0, this.Width, this.Height); When I enable both AllPaintingInWmPaint and DoubleBuffer, parts of the form don't get painted. I'm not sure what exactly happens, but here is an image: http://www.subspacedownloads.com/db.jpg[^] On the image, I dragged the window from behind the left edge fast(If I do it slow, it gets painted almost completely. Leaves 2-5 pixels to the left). How do I fix this?

    L C 2 Replies Last reply
    0
    • S S O S

      Form an article, I read that this enables double buffering on a form: SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.UserPaint, true); Well I tried it, using this code on an MDI child: Graphics g = CreateGraphics(); g.FillRectangle(new SolidBrush(somecolour), 0, 0, this.Width, this.Height); When I enable both AllPaintingInWmPaint and DoubleBuffer, parts of the form don't get painted. I'm not sure what exactly happens, but here is an image: http://www.subspacedownloads.com/db.jpg[^] On the image, I dragged the window from behind the left edge fast(If I do it slow, it gets painted almost completely. Leaves 2-5 pixels to the left). How do I fix this?

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      I dont think you can UserPaint with the other two. Why are you using UserPaint? You should only use that AFAIK when you want to completely render the control without any help from Windows. I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02

      S 1 Reply Last reply
      0
      • L leppie

        I dont think you can UserPaint with the other two. Why are you using UserPaint? You should only use that AFAIK when you want to completely render the control without any help from Windows. I rated this article 2 by mistake. It deserves more. I wanted to get to the second page... - vjedlicka 3:33 25 Nov '02

        S Offline
        S Offline
        S O S
        wrote on last edited by
        #3

        Well, the artice said to use that... anyway, that's not important. I'm getting the error just with the first 2.

        1 Reply Last reply
        0
        • S S O S

          Form an article, I read that this enables double buffering on a form: SetStyle(ControlStyles.AllPaintingInWmPaint, true); SetStyle(ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.UserPaint, true); Well I tried it, using this code on an MDI child: Graphics g = CreateGraphics(); g.FillRectangle(new SolidBrush(somecolour), 0, 0, this.Width, this.Height); When I enable both AllPaintingInWmPaint and DoubleBuffer, parts of the form don't get painted. I'm not sure what exactly happens, but here is an image: http://www.subspacedownloads.com/db.jpg[^] On the image, I dragged the window from behind the left edge fast(If I do it slow, it gets painted almost completely. Leaves 2-5 pixels to the left). How do I fix this?

          C Offline
          C Offline
          Chris Jobson
          wrote on last edited by
          #4

          I think that the problem is that your painting code (which I assume is in the Paint event handler) should use the Graphics object from the PaintEventArgs parameter rather than creating its own. This seems to fix the problem. Chris Jobson

          S 1 Reply Last reply
          0
          • C Chris Jobson

            I think that the problem is that your painting code (which I assume is in the Paint event handler) should use the Graphics object from the PaintEventArgs parameter rather than creating its own. This seems to fix the problem. Chris Jobson

            S Offline
            S Offline
            S O S
            wrote on last edited by
            #5

            Aah, yees, that might be it. Thanks.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups