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 can I avoid the fliker of a form?

How can I avoid the fliker of a form?

Scheduled Pinned Locked Moved C#
question
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.
  • A Offline
    A Offline
    anuo06
    wrote on last edited by
    #1

    Maybe because I used too many controls,my application has the phenomenon of flicker.I used SetStyle function like this: this.SetStyle( ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true); but it seems no use. how can I avoid it?

    L 1 Reply Last reply
    0
    • A anuo06

      Maybe because I used too many controls,my application has the phenomenon of flicker.I used SetStyle function like this: this.SetStyle( ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true); but it seems no use. how can I avoid it?

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      according to the documentation you should call UpdateStyles() after setting the style bits :)

      Luc Pattyn

      A 1 Reply Last reply
      0
      • L Luc Pattyn

        according to the documentation you should call UpdateStyles() after setting the style bits :)

        Luc Pattyn

        A Offline
        A Offline
        anuo06
        wrote on last edited by
        #3

        I have tried according your advice,but it is no use just as before,my code like the following ,is it right?Maybe I should write it in another way. public FormRecite() { InitializeComponent(); this.SetStyle( ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true); this.UpdateStyles(); mainFormRecite=this; this.sqlConnection1.Close(); }

        D L 2 Replies Last reply
        0
        • A anuo06

          I have tried according your advice,but it is no use just as before,my code like the following ,is it right?Maybe I should write it in another way. public FormRecite() { InitializeComponent(); this.SetStyle( ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true); this.UpdateStyles(); mainFormRecite=this; this.sqlConnection1.Close(); }

          D Offline
          D Offline
          DiegoValdevino
          wrote on last edited by
          #4

          You've said your Form has a huge number of controls on it. Maybe you should do double buffer on the controls too.

          1 Reply Last reply
          0
          • A anuo06

            I have tried according your advice,but it is no use just as before,my code like the following ,is it right?Maybe I should write it in another way. public FormRecite() { InitializeComponent(); this.SetStyle( ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint | ControlStyles.DoubleBuffer, true); this.UpdateStyles(); mainFormRecite=this; this.sqlConnection1.Close(); }

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #5

            Hi, In my applications, I usually use LPW_DoubleBufferedPanel instances, where LPW_DoubleBufferedPanel simply inherits from Panel, while setting the three style bits in its constructor (the SetStyle method is protected, so you can not call it from outside the panels). using System; using System.Windows.Forms; namespace LP_Basics { //################################################################################ /// /// LPW_DoubleBufferedPanel is a panel that uses double buffering to avoid flicker. /// //################################################################################ [System.ComponentModel.DesignerCategory("Code")] public class LP_DoubleBufferedPanel : Panel { /// /// Construct a double buffered Panel. /// public LP_DoubleBufferedPanel() { // set 3 bits to get double buffering SetStyle(System.Windows.Forms.ControlStyles.DoubleBuffer,true); SetStyle(System.Windows.Forms.ControlStyles.AllPaintingInWmPaint,true); SetStyle(System.Windows.Forms.ControlStyles.UserPaint,true); } } } (remark: I don't need the UpdateStyles method here since the Panel's handle has not been created yet, so the panel is born with the new style settings). Following your mail, I have tried SetStyles on a form, and it does not work the way you and I would hope. It seems the double buffering characteristic is not inherited by its children. So I suggest you start using LPW_DoubleBufferedPanel and the like. I admit, if you need a lot of different kinds of Controls, this may become cumbersome. :(

            Luc Pattyn

            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