1
votes

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.)

2
Windows itself as an optimization will repaint with the previous screen contents, then allow your program to repaint the window properly. I'm not sure what you can do about the automatic part of the process.Mark Ransom
@MarkRansom: Not even for the nonclient area? It's not just the client area that has this problem.user541686
You might also look at stackoverflow.com/a/5739620/5987 for my own solution to the resizing problem.Mark Ransom
@MarkRansom: Thanks, I'll take a look.user541686
I seem to remember having trouble with this on XP with themes enabled. If I dragged the left border of a window the right border would wobble. However, the wobble didn't happen on earlier versions of Windows or Windows 7. And I think it was OK on XP with the classic look, because I eventually concluded that it was a bug in XP's themes engine.arx

2 Answers

1
votes

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

0
votes

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)?