Refresh a region in window before drawing text
I'm drawing text on window at WM_PAINT message, is there any way i can refresh that window region before drawing a new line of text so the old tex开发者_开发百科t at the same location would get erased?
You need to call InvalidateRect for the window with the bErase
parameter set to TRUE
so that it will erase itself before the WM_PAINT is generated.
This is often required when the window is a static text control, as those don't erase themselves automatically when you change their value.
Make sure your window is handling WM_ERASEBKGND properly and the window class doesn't have a NULL background brush, as this is the mechanism used by InvalidateRect to do the erasing.
You could just FillRect over the old text first...
HDC hdc = GetDC(NULL); //get windows handle whaterver if urs
HRGN hrgn;
//get that specific region and repaint it by following line
hrgn = CreateRectRgn(10, 10, 100, 100);
SelectClipRgn(hDC, hrgn);
PaintDesktop(hDC);
精彩评论