抑制WM_ERASEBKGND的正确方法是什么? [英] What is the correct way to suppress WM_ERASEBKGND?

查看:329
本文介绍了抑制WM_ERASEBKGND的正确方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果需要使用双缓冲,则需要禁止显示WM_ERASEBKGND消息.

If I need to use double buffering, I need to suppress WM_ERASEBKGND message.

我可以处理WM_ERASEBKGND并立即返回.但是我可以将WNDCLASS/WNDCLASSEXhbrBackground设置为NULL而不处理WM_ERASEBKGND消息吗?这是正确的方法吗?

I can handle WM_ERASEBKGND and return immediately. But can I set the WNDCLASS/WNDCLASSEX's hbrBackground to NULL and not handle the WM_ERASEBKGND message? Is this a correct way?

推荐答案

是的,将hbrBackground设置为NULL是避免实现无操作WM_ERASEBKGND处理程序的适当方法.

Yes, setting hbrBackground to NULL is an appropriate way to avoid implementing a no-op WM_ERASEBKGND handler.

WM_ERASEBKGND传递给DefWindowProc时,它将检查窗口类中的背景画笔.如果有一个,它将用它填充脏区.如果背景画笔为空,则不执行任何操作并返回.基本上与拥有自己的WM_ERASEBKGND不执行处理程序相同.

When you pass WM_ERASEBKGND on to DefWindowProc, it checks the background brush in the window's class. If there is one, it fills the dirty region with it. If the background brush is null, it does nothing and returns. That's essentially the same as having your own do-nothing WM_ERASEBKGND handler.

WM_ERASEBKGND处理程序的返回值会影响WM_PAINT调用BeginPaint时获得的PAINTSTRUCTfErase字段. WM_PAINT处理程序应该检查fErase以了解它是否需要擦除背景本身,或者是否已经被WM_ERASEBKGND完成. (尽管我从未真正看到任何人对其进行过检查.)如果让DefWindowProc处理WM_ERASEBKGND,如果它具有颜色编号或画笔,它将返回TRUE,如果hbrBackgroundNULL,它将返回FALSE.

The return value from the WM_ERASEBKGND handler affects the fErase field of the PAINTSTRUCT you get when WM_PAINT calls BeginPaint. The WM_PAINT handler is supposed to check fErase to find out whether it needs to erase the background itself or if it was already done by WM_ERASEBKGND. (Though I've never actually seen anyone check it.) If you let DefWindowProc handle WM_ERASEBKGND it will return TRUE if it has a color number or brush and FALSE if the hbrBackground is NULL.

这篇关于抑制WM_ERASEBKGND的正确方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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