开发者

Refresh a region in window before drawing text

开发者 https://www.devze.com 2023-01-19 07:10 出处:网络
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 erase

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); 
0

精彩评论

暂无评论...
验证码 换一张
取 消