On Win32, can I turn off window coloring for a certain period of time?

Is there a function that freezes redrawing windows for some time while I make changes to the layout of my dialog?

+3
source share
3 answers

If you find that you really need to do this, you should send a WM_SETREDRAW message box with the wParam parameter set to FALSE. This means that the window should not be redrawn after changing its contents.

If you want to turn on drawing again, send another WM_SETREDRAW message, this time with wParam set to TRUE.

Code example:

 // 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 this subject is a great read.

+15
source

You have to do repositioning in one fell swoop; use BeginDeferWindowPos et al.

+4
source

The way Windows draws is that the system sends your WM_PAINT windows messages instructing you to draw. You can choose to ignore these messages if you want, while you are changing the layout, and then forcefully complete the drawing cycle after you finish changing the layout.

However, my experience with writing an interface in Windows is that you usually don't need to take such steps. Since you are responsible for pumping the message queue, if the window is updated while you are in the middle of a layout change, you must take measures that led to the pumping of the message queue.

Simply put, stop pumping the queue when you change the layout, and your problems will disappear.

+2
source

Source: https://habr.com/ru/post/1442596/


All Articles