TONT 40943 白光一闪

请注意:本页内容发布于 2185 天前,内容可能已经过时,请注意甄别。

神说,要有光。什么,已经崩溃了?那也得有。

原文链接:https://blogs.msdn.microsoft.com/oldnewthing/20040123-00/?p=40943

If you had a program that didn’t process messages for a while, but it needed to be painted for whatever reason (say, somebody uncovered it), Windows would eventually lose patience with you and paint your window white.

如果某个应用程序在一段时间内未能处理窗体消息,但却不论出于任何原因需要被描绘(例如,其上有其它窗口移开了),Windows最终会失去信心,并用白色将窗体涂一个遍。

Or at least, that’s what people would claim. Actually, Windows is painting your window with your class background brush. Since most people use COLOR_WINDOW and since COLOR_WINDOW is white in most color schemes, the end result is a flash of white.

或者,至少这是人们这么说的。实际上Windows是用你的类中的背景笔刷把窗体涂满的。鉴于多数人使用COLOR_WINDOW,而COLOR_WINDOW在大多数配色方案中又是白色,最终结果就是一道白色的闪电。

Why paint the window white? Why not just leave it alone?

为什么要将窗体涂成白色呢,干脆不管它不是更好吗?

Well, that’s what it used to do, but the result was that the previous contents of the screen would be shown where the window “would be”. So suppose you were looking at Explorer, and then you restored a program that stopped responding. Inside the program’s main window would be… a picture of Explorer. And then people would try to double-click on what they thought was Explorer but was really a hung program.

其实呢,过去的确是这样处理的,但是这样做的结果是之前显示在屏幕上的内容被嵌在(停止响应的程序的)窗体『将要』出现的地方。假设你之前在浏览资源管理器,然后还原了一个已经停止响应的应用程序,(按照过去的设计)在这个程序的主窗口中出现的……将是资源管理器的(残留)图像。然后用户们就会尝试去双击他们以为是资源管理器的地方,但事实上是在点那个已经挂了的程序罢了。

In Windows XP, the behavior for a window that has stopped painting is different. Now, the system captures the pixels of the unresponsive window and just redraws those pixels if the window is unable to draw anything itself. Note, however, that if the system can’t capture all of the pixels – say because the window was partially covered – then the parts that it couldn’t get are filled in with the class brush.

在Windows XP中,针对停止绘制自己的窗体的行为有所变化。现如今,系统会捕获这个无响应窗体的像素点,然后在其无法自行进行绘制时,由系统(用记录下来的像素点)进行重绘。不过,请注意如果系统无法获取到所有的像素点——例如该窗口被部分遮挡了,那么那部分窗体就会由窗体类的笔刷进行填充。

Which is usually white.

而这个笔刷通常就是白色的。

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

 剩余字数 ( Characters available )

Your comment will be available after auditing.
您的评论将在通过审核后显示。

Please DO NOT add any links in your comment, otherwise it would be identified as SPAM automatically and never be audited.
请不要在评论中插入任何链接,否则将被自动归类为垃圾评论,且永远不会被提交给博主进行复审。

*