Wednesday, May 23, 2018

Why is this WinForms window rendering artifacts while dragging?

Leave a Comment

I'm supporting a .NET 4 WinForms app written in VB.NET and built w/ Visual Studio 2015. In Windows 7 things are fine, but in our Windows 10 testing there is a rendering problem with a form window in the main application window. Happens on multiple machines (all Dell laptops). Dragging form window quickly, and over the main window’s top or bottom edges (highlighted in yellow in screenshot), causes it to freak out and leave graphical artifacts, like so:

enter image description here

Are there window properties or settings that can be adjusted to prevent this?

thanks!

2 Answers

Answers 1

The repainting issues are generally attributed to the fact that the main thread may be locked doing some process and is not able to repaint. Are you using multithreaded approach in your application. A good starting point would be to check if there is anything locking the main thread.

Answers 2

Each WinForms Control has a property called DoubleBuffered. It is intended to reduce such unwanted effects. When double buffering is enabled, the rendering operations take place in the memory first. Then only the last one is applied to the graphics device. More details here.

Double buffering is disabled by default for forms. So setting the DoubleBuffered property for your form to true will resolve the problem.

UPDATE

I misread the comment stating that the DoubleBuffered is already set. Please, make sure the DoubleBuffered property is set for both your MDI child and MDI parent forms. Also, make sure that the driver for the graphics card is the manufacturer provided as opposed to the default one.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment