Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

On Win32, can I disable painting of a window for a period of time?

Is there a function that will freeze window repainting for some time, while I do changes to the layout of my dialog?

like image 504
sashoalm Avatar asked Feb 15 '11 09:02

sashoalm


2 Answers

If you find that you actually need to do this, you should send the window a WM_SETREDRAW message with the wParam set to FALSE. This indicates that the window should not be redrawn after its contents are changed.

When you want to re-enable drawing, send another WM_SETREDRAW message, this time with the wParam set to TRUE.

Sample code:

// Disable window updates
SendMessage(hWnd, WM_SETREDRAW, FALSE, 0);

// Perform your layout here
// ...

// Re-enable window updates
SendMessage(hWnd, WM_SETREDRAW, TRUE, 0);

For more information, Raymond Chen's blog article on the subject is a great read.

like image 84
Cody Gray Avatar answered Nov 05 '22 17:11

Cody Gray


You should do the repositioning in a single swoop; use BeginDeferWindowPos et al.

like image 4
avakar Avatar answered Nov 05 '22 17:11

avakar