Question

If you drag the top or left border of a window semi-quickly, you should notice that the opposite edge of the window vibrates -- it gets dragged, but then re-adjusts to increase the size.

The problem is a lot worse when you have items that dynamically resize -- then a bunch of your controls start sliding and resizing on the screen, quite visibly.

Is there any way to prevent these transient effects?

e.g. Perhaps a particular sequence of responding to messages like WM_SIZE can suppress this? I don't know.

(It seems to happen in every framework I've seen, even plain Win32. Just open up Explorer or something and drag its top or left edge, and you'll see what I mean.)

Was it helpful?

Solution

Respond to the WM_WINDOWPOSCHANGING message and set the SWP_NOCOPYBITS flag in the flags member of the WINDOWPOS structure.

OTHER TIPS

A 2018 update. The WM_WINDOWPOSCHANGING and related WM_NCCALCSIZE tricks often mentioned on SO worked well for XP/Vista/7 but are no longer enough for Win8/10 because Aero adds on a new layer of resize problems that mask, or worsen, the older problems.

The Win8/10 problem is much harder to solve because the unwanted copy of your pixels is happening in DWM.exe, another process that composites pixels from all the apps on the system.

Please see this Q&A for an explanation of what is going on, some sample code with WM_NCCALCSIZE to solve the problem at the XP/Vista/7 layer (which is still there in Win8/10!), and a partial solution for 8/10.

How to smooth ugly jitter/flicker/jumping when resizing windows, especially dragging left/top border (Win 7-10; bg, bitblt and DWM)?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top