CWnd::OnEraseBkgnd(MSDN)

(还需要修改!!)

The framework calls this member function when the CWnd object background needs erasing (for example, when resized).

afx_msg BOOL OnEraseBkgnd( CDC* pDC );

It is called to prepare an invalidated regionfor painting.

The default implementation erases the background using the window class background brush specified by thehbrBackground member of the window class structure.

缺省的实现使用窗口类结构中hbrBackground成员指定的窗口类背景刷子擦除窗口背景。

If the hbrBackground member is NULL, your overridden version ofOnEraseBkgnd should erase the background color. Your version should also align the origin of the intended brush with theCWnd coordinates by first calling UnrealizeObject for the brush, and then selecting the brush.

An overridden OnEraseBkgnd should return nonzero in response toWM_ERASEBKGND if it processes the message and erases the background; this indicates that no further erasing is required. If it returns 0, the window will remain marked as needing to be erased. (Typically, this means that thefErase member of the PAINTSTRUCT structure will beTRUE.)

Windows assumes the background is computed with the MM_TEXT mapping mode. If the device context is using any other mapping mode, the area erased may not be within the visible part of the client area.

Note:

This member function is called by the framework to allow your application to handle a Windows message. The parameters passed to your function reflect the parameters received by the framework when the message was received. If you call the base-class implementation of this function, that implementation will use the parameters originally passed with the message and not the parameters you supply to the function.



 问: OnEraseBkgnd函数中返回TRUE或FALSE有什么区别?

  答: true表示已处理背景刷新,false表示需要在OnPaint里处理
  问:在OnEraseBkgnd中绘制对话框的背景图片和在OnPaint中绘制对话框的背景图片由什么区别,另外OnEraseBkgnd和CtlColor有什么区别?
  答: OnEraseBkgnd是在窗口大小发生改变等情况下发生的,它将绘制窗口背景;而OnCtlColor是当窗口的控件需要绘制时发生的,它将绘制窗口的控件。 A:OnEraseBkgnd :在窗口背景需要重绘时调用.OnPaint : 此时OnEraseBkgnd已经调用过了,所以在此响应函数体内对背景进行的操作将覆盖OnEraseBkgnd中所做的操作.OnCtlColor : 有于在窗口将要被(第一次)绘制时响应,子窗口可以通过发关WM_CTLCOLOR请求父窗口传来一个HBRUSH.


默认的函数

BOOL CdirectUITestDlg::OnEraseBkgnd(CDC* pDC)
{
	return CDialog::OnEraseBkgnd(pDC);
}

如果改为下面代码,则绘制背景为白色。

BOOL CdirectUITestDlg::OnEraseBkgnd(CDC* pDC)
{
//return CDialog::OnEraseBkgnd(pDC);
return true;
}




  问: OnEraseBkgnd函数中返回TRUE或FALSE有什么区别?
  答: WM_ERASEBKGNDReturn ValuesAn application should return nonzero if it erases the background; otherwise, it should return zero. A:true表示已处理背景刷新,false表示需要在OnPaint里处理
  问:在OnEraseBkgnd中绘制对话框的背景图片和在OnPaint中绘制对话框的背景图片由什么区别,另外OnEraseBkgnd和CtlColor有什么区别?
  答: OnEraseBkgnd是在窗口大小发生改变等情况下发生的,它将绘制窗口背景;而OnCtlColor是当窗口的控件需要绘制时发生的,它将绘制窗口的控件。 A:OnEraseBkgnd :在窗口背景需要重绘时调用.OnPaint : 此时OnEraseBkgnd已经调用过了,所以在此响应函数体内对背景进行的操作将覆盖OnEraseBkgnd中所做的操作.OnCtlColor : 有于在窗口将要被(第一次)绘制时响应,子窗口可以通过发关WM_CTLCOLOR请求父窗口传来一个HBRUSH.
  问: OnEraseBkgnd函数中返回TRUE或FALSE有什么区别?
  答: WM_ERASEBKGNDReturn ValuesAn application should return nonzero if it erases the background; otherwise, it should return zero. A:true表示已处理背景刷新,false表示需要在OnPaint里处理
  问:在OnEraseBkgnd中绘制对话框的背景图片和在OnPaint中绘制对话框的背景图片由什么区别,另外OnEraseBkgnd和CtlColor有什么区别?
  答: OnEraseBkgnd是在窗口大小发生改变等情况下发生的,它将绘制窗口背景;而OnCtlColor是当窗口的控件需要绘制时发生的,它将绘制窗口的控件。 A:OnEraseBkgnd :在窗口背景需要重绘时调用.OnPaint : 此时OnEraseBkgnd已经调用过了,所以在此响应函数体内对背景进行的操作将覆盖OnEraseBkgnd中所做的操作.OnCtlColor : 有于在窗口将要被(第一次)绘制时响应,子窗口可以通过发关WM_CTLCOLOR请求父窗口传来一个HBRUSH.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值