How to avoid transient updates in a GUI resize?
Asked Answered
F

2

1

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

Fellmonger answered 5/7, 2012 at 22:37 Comment(4)
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.Sidon
@MarkRansom: Not even for the nonclient area? It's not just the client area that has this problem.Fellmonger
You might also look at https://mcmap.net/q/261401/-how-to-create-a-resizable-cdialog-in-mfc for my own solution to the resizing problem.Sidon
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.Edsel
S
1

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

Sidon answered 5/7, 2012 at 22:55 Comment(4)
Doesn't that only affect the client area?Fellmonger
@Mehrdad, I believe you're right. I didn't notice any non-client problems though, at least in Windows 7.Sidon
Oooh, I just noticed... yes, the nonclient area is copied and the new part is repainted, but unlike what I thought, it's not moved! I got that illusion because the client area moved haha. Interesting, I'll take a better look at this, thanks.Fellmonger
Yup, seems a lot better! I still see a slight erase/paint when it's repainting, any idea how to get rid of that (or if it's even possible)?Fellmonger
A
0

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

Auroraauroral answered 26/10, 2018 at 9:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.