how to stop flickering C# winforms

前端 未结 16 2304
故里飘歌
故里飘歌 2020-11-28 04:16

I have a program that is essentially like a paint application. However, my program has some flickering issues. I have the following line in my code (which should get rid of

16条回答
  •  难免孤独
    2020-11-28 04:55

    If memory is tight (so you don't want the memory cost of double-buffering), one possible way to REDUCE, though not eliminate, flicker, is to set background color to the dominant color in your current scene.

    Why this helps: flicker is a momentary flash of the background color, which the OS draws before drawing child controls or your custom drawing code. If that flash is a color that is closer to the final color to be displayed, it will be less noticeable.

    If you are not sure what color to start with, start with 50% gray, because this is an average of black and white, so will be closer to most colors in your scene.

    myFormOrControl.BackColor = Color.Gray;
    

提交回复
热议问题