Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Prevent repainting of window in C++

Tags:

I am writing a global hook DLL that needs to do some drawing using GDI+ on a window in response to an event. My problem is that the window that is being drawn keeps repainting itself, so what I draw gets erased before I want it to. Is there any way I can prevent the window from painting anything for as long as I need to?

My hook currently is a WH_CALLWNDPROC hook. The drawing is done using GDI+ in response to the message WM_SIZING. I drawing using GDI+ onto the window's DC (i.e. GetWindowDC). What I am drawing is drawn correctly, but gets erased almost instantly as the window client area gets repainted. The program that created the window I am drawing on is Notepad. As the cursor blinks, what I have drawn gets erased.

Does anyone know of a way I can temporarily suspend painting of the window?

Thanks!

like image 491
AniDev Avatar asked Nov 23 '10 21:11

AniDev


1 Answers

I would suggest putting your graphics in a layered window overlapping the target window. That seems to be the cleanest way. After all, at some level of conception, this is the purpose of the window manager :)

like image 100
tenfour Avatar answered Oct 13 '22 07:10

tenfour