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. GDI+ flicker when drawing to a panel

GDI+ flicker when drawing to a panel

Scheduled Pinned Locked Moved C#
graphicsquestionwinforms
4 Posts 2 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.
  • J Offline
    J Offline
    JDUK
    wrote on last edited by
    #1

    I have a panel inside a form im drawing to becuase the drawing space needs to be bigger than the form and the user needs to be able to scroll round the image using the form scroll bars.. i have used SetStyle(ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); to try and stop the flicker but it only works when the form itself is drawn to. How do i get double buffering to work on the panel? Thanks.

    J 1 Reply Last reply
    0
    • J JDUK

      I have a panel inside a form im drawing to becuase the drawing space needs to be bigger than the form and the user needs to be able to scroll round the image using the form scroll bars.. i have used SetStyle(ControlStyles.DoubleBuffer, true); SetStyle(ControlStyles.UserPaint, true); SetStyle(ControlStyles.AllPaintingInWmPaint, true); to try and stop the flicker but it only works when the form itself is drawn to. How do i get double buffering to work on the panel? Thanks.

      J Offline
      J Offline
      JDUK
      wrote on last edited by
      #2

      This problem has been plauging me for weeks.... then a minuite i post this i stubmle across the solution (more by luck than judgment) .. sods law, hey? All sorted now thanks. :D

      J 1 Reply Last reply
      0
      • J JDUK

        This problem has been plauging me for weeks.... then a minuite i post this i stubmle across the solution (more by luck than judgment) .. sods law, hey? All sorted now thanks. :D

        J Offline
        J Offline
        Judah Gabriel Himango
        wrote on last edited by
        #3

        You care to post your solution? There are thousands of others with the same flicker problem.

        Tech, life, family, faith: Give me a visit. I'm currently blogging about: Conversation With a Muslim Judah Himango

        J 1 Reply Last reply
        0
        • J Judah Gabriel Himango

          You care to post your solution? There are thousands of others with the same flicker problem.

          Tech, life, family, faith: Give me a visit. I'm currently blogging about: Conversation With a Muslim Judah Himango

          J Offline
          J Offline
          JDUK
          wrote on last edited by
          #4

          Yeah sorry about that... I hate it when I search for a problem and the OP says "sorted" and it just dies right then and there, to. So here goes: My Drawing function looked like this(Though it has been drasticly cut down to the bare minimum for readability): private void DrawMyStuff() { System.Drawing.Graphics myGraphics; myGraphics = myPanel.CreateGraphics(); MyGraphics.DrawImage(myBitmap, x*Size,y*Size); MyGraphics.Dispose(); } My panels paint method looked like this private void myPanel_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { DrawMyStuff(); } I have since changed it to look like this: private void DrawMyStuff(Graphics g) { g.DrawImage(myBitmap, x, y); g.Dispose(); } & private void myPanel_Paint(object sender, System.Windows.Forms.PaintEventArgs e) { DrawMyStuff(e.Graphics); } I think my problem was re-assigning the graphics object every time and in a way bybassing the double buffering by recreating the drawing surface constantly. Hope that helps some people...

          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