从左侧调整时,闪烁的窗口 [英] Flickering on window when resizing from left side

查看:214
本文介绍了从左侧调整时,闪烁的窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

看来,每当我移动和窗口,并在同一时间调整我的窗口闪烁。这通常在上浆从窗口的左边所做发生。

It seems that my window is flickering whenever I move and window and resize at the same time. This usually occurs when sizing is done from the left side of the window.

为什么会出现这种闪烁发生的呢?换句话说,什么是当你重新定位的窗口操作系统做什么?

Why does this flickering happen? In other words, what is the OS doing when you reposition a window?

请注意:从右侧,这意味着窗口大小调整不一定是移动它的起源X和时,我没有遇到闪烁是

Note: I do not experience flickering when resizing from the right side which means the window is not necessarily moving its origin X and Y.

推荐答案

调整Windows下一个窗口,涉及到操作系统和窗口的句柄(的 WNDCLASSEX 使用的 注册窗口的类)。你可以使用一些邮件监控工具自己发现它们。 间谍++ 随Visual Studio是一个这样的工具。

Resizing a window under Windows involves several messages sent between the OS and the window's handler (the lpfnWndProc member of WNDCLASSEX structure used to register the window's class). You can discover them by yourself using some message monitoring tool. Spy++ that comes with Visual Studio is one such tool.

一个有趣的消息是 WM_NCCALCSIZE :此消息,窗口大小调整过程中调用,可以产生两个矩形(当WVR_VALIDRECTS标志设置):源和目标指定哪些旧的窗口的客户区的内容可以在新窗口的位置重用。默认情况下它的假设左上角是一个支点:

One interesting message is WM_NCCALCSIZE: this message, called during window resizing, can generate two rectangles (when WVR_VALIDRECTS flag is set): source and target specifying what content of the old window's client area can be "reused" at the new window's position. By default it's assumed that the top-left corner is a pivot:


  • 调整左侧或顶部边框导致旧的窗口的内容被复制到preserve枢轴;

  • 调整权OT底部边框拷贝任何操作,因为窗口的左上角不​​动了。

这默认的复制可以导致闪烁,如果它不重绘时对应方式,你的位置的视觉效果。例如,相对于右侧或底部边框显示的一切都将被后错位从左侧或顶部边框调整:这些物体会感动不必要的这种调整大小后留下的新旧事物奇怪的混合,因为只有非复制的像素将被粉刷一新。如果你试图用的 InvalidateRect 期间,比方说,WM_SIZE你会得到闪烁(时间间隔里的东西放错地方很短,但它仍然存在)。

This default copying can cause flicker, if it does not correspond to the way you position visuals during repaint. For example, everything that is displayed relative to the right or bottom border will be misplaced after resize from the left or top border: these objects will get moved unnecessarily leaving strange mix of old and new things after such resize, because only non-copied pixels will be repainted. If you try to cure the mess with InvalidateRect during, say, WM_SIZE you will get the flicker (the time interval where things are misplaced is very short but it still exists).

要禁用此行为,最简单的方法是通过设置CS_HREDRAW CS_VREDRAW和的类样式了解你的窗口。

The easiest way to disable this behavior is by setting the CS_HREDRAW and CS_VREDRAW Class Styles for your window.

这篇关于从左侧调整时,闪烁的窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆