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. how to avoid panel flicker ?

how to avoid panel flicker ?

Scheduled Pinned Locked Moved C#
graphicshelptutorialquestion
3 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.
  • U Offline
    U Offline
    User 10853414
    wrote on last edited by
    #1

    Hi, I'm desperate: I cannot eliminate that fastidious flicker that occurs when a panel is redrawn (it has to been redrawn every 150ms so it's not a CPU issue). I've tried with this.SetStyle( ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer,true); after the "InitializeComponent();" call, but it doesn't help. Then I tried doing all drawing operations on a Bitmap, and at the end draw the Bitmap on the form: no relevant effects. (a sort of manual doubleBuffer) the source code can be found at this URL: http://utenti.lycos.it/yuppygames/codeproject/flicker.zip Please, can you check my code or suggest another method? thank you

    C 1 Reply Last reply
    0
    • U User 10853414

      Hi, I'm desperate: I cannot eliminate that fastidious flicker that occurs when a panel is redrawn (it has to been redrawn every 150ms so it's not a CPU issue). I've tried with this.SetStyle( ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.DoubleBuffer,true); after the "InitializeComponent();" call, but it doesn't help. Then I tried doing all drawing operations on a Bitmap, and at the end draw the Bitmap on the form: no relevant effects. (a sort of manual doubleBuffer) the source code can be found at this URL: http://utenti.lycos.it/yuppygames/codeproject/flicker.zip Please, can you check my code or suggest another method? thank you

      C Offline
      C Offline
      colderthanfusion
      wrote on last edited by
      #2

      Drawing the bitmap directly on to your form instead of using a Panel will help. Get rid of panel1 completely and move the drawing code to an override of Form1. Try protected override void OnPaint(PaintEventArgs e) { base.OnPaint (e); e.Graphics.DrawImage( //draw shade shade barran, new Rectangle(160, 4, 299, 32), // destination rectangle 0.0f, // source rectangle x 0.0f, // source rectangle y 299, // source rectangle width 32, // source rectangle height GraphicsUnit.Pixel, imageAtt); e.Graphics.DrawImageUnscaled(temp2,new Rectangle(160+xtitolo,7,287,27)); //draw title } Then in timertitolo_Tick method Invalidate() the form rather than panel1

      J 1 Reply Last reply
      0
      • C colderthanfusion

        Drawing the bitmap directly on to your form instead of using a Panel will help. Get rid of panel1 completely and move the drawing code to an override of Form1. Try protected override void OnPaint(PaintEventArgs e) { base.OnPaint (e); e.Graphics.DrawImage( //draw shade shade barran, new Rectangle(160, 4, 299, 32), // destination rectangle 0.0f, // source rectangle x 0.0f, // source rectangle y 299, // source rectangle width 32, // source rectangle height GraphicsUnit.Pixel, imageAtt); e.Graphics.DrawImageUnscaled(temp2,new Rectangle(160+xtitolo,7,287,27)); //draw title } Then in timertitolo_Tick method Invalidate() the form rather than panel1

        J Offline
        J Offline
        JockerSoft
        wrote on last edited by
        #3

        thank you very much. I did what you said and now it works. I can't believe it was panel's fault! I created that panel because I wanted to avoid repainting every single pixel of the form thinking it was faster :mad: if anyone wants to see the correct code, click here: http://utenti.lycos.it/yuppygames/codeproject/flicker2.zip thank you again colderthanfusion

        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