G
Guest
I would lilke to know what is the best (most efficient) way to paint a
control. I was told that if you call Invalidate(Rectangle) Windows will
calculate the bounding rectangle of the current invalid rectangle and the
supplied rectangle (the one passed in the call). This seems like a
sub-optimal approach. Consider a grid in which the top left cell is
invalidated and the bottom right cell is invalidated. The bounding rectangle
is the entire grid. I've looked a bit at regions and it appears as if
regions solves this problem. From what I read it appears if you invalidate a
region Windows will add that region to the invalid regions list and will
continue to send the control WM_PAINT messages until the invalid region list
is empty.
If my above statements are correct I would expect the .NET controls to make
use of regions as opposed to rectangles when it comes to invalidating a
control. However, it appears DataGridView.InvalidateCell() calls
Control.Invalidate(Rectangle) as opposed to Control.Invalidate(Region). Why?
control. I was told that if you call Invalidate(Rectangle) Windows will
calculate the bounding rectangle of the current invalid rectangle and the
supplied rectangle (the one passed in the call). This seems like a
sub-optimal approach. Consider a grid in which the top left cell is
invalidated and the bottom right cell is invalidated. The bounding rectangle
is the entire grid. I've looked a bit at regions and it appears as if
regions solves this problem. From what I read it appears if you invalidate a
region Windows will add that region to the invalid regions list and will
continue to send the control WM_PAINT messages until the invalid region list
is empty.
If my above statements are correct I would expect the .NET controls to make
use of regions as opposed to rectangles when it comes to invalidating a
control. However, it appears DataGridView.InvalidateCell() calls
Control.Invalidate(Rectangle) as opposed to Control.Invalidate(Region). Why?