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.
source share