关于WTL中对WM_PAINT中的处理
2010-10-12 23:48
423 查看
WTL8.0中的atlcrack.h对窗口消息进行了解码,因为windows消息一般由wParam和lParam传递,这样使用起来不方便。但对WM_PAINT解码成OnPaint(HDC hDC),hDC一直都为NULL,查看了atlcrack.h(也只能查看其代码了,因为没有文档的),发现其代码是这样写的:
实际上窗口接收到WM_PAINT消息时,需要调用BeginPaint来获取窗口DC,而wParam和lParam一直为0的。那dc参数有何用?
起初我以为是BUG,后来我发现WINCE下WM_PAINT消息是不一样的。
WINCE下是
WTL并没有文档说明OnPaint参数的用途,让用户感到迷惑,当然要使用WTL的话也只能这样,摸着石头过河。
// void OnPaint(CDCHandle dc) #define MSG_WM_PAINT(func) / if (uMsg == WM_PAINT) / { / SetMsgHandled(TRUE); / func((HDC)wParam); / lResult = 0; / if(IsMsgHandled()) / return TRUE; / }
实际上窗口接收到WM_PAINT消息时,需要调用BeginPaint来获取窗口DC,而wParam和lParam一直为0的。那dc参数有何用?
起初我以为是BUG,后来我发现WINCE下WM_PAINT消息是不一样的。
WINCE下是
WM_PAINT hdc = (HDC) wParam;
Parameters
hdc Handle to the device context to draw in. If this parameter is NULL, use the default device context. This parameter is used by some common controls to enable drawing in a device context other than the default device context. Other windows can safely ignore this parameter.
WTL并没有文档说明OnPaint参数的用途,让用户感到迷惑,当然要使用WTL的话也只能这样,摸着石头过河。
相关文章推荐
- 关于WTL中对WM_PAINT中的处理
- TWinControl.DefaultHandler里的CallWindowProc(FDefWndProc)还挺有深意的,TButton对WM_PAINT消息的处理就是靠它来处理的(以前不明白为什么总是要调用inherited,其实就是没有明白TWinControl.DefaultHandler的真正用处,而且还很有用)
- WM_PAINT消息造成CPU卡死的原因。。。。关于CDialog类和CWnd类的WM_PAINT消息的理解
- 关于控件重载WM_PAINT消息
- 关于WM_PAINT消息
- Windows Mobile学习笔记_关于csliderbar和wm_hscroll消息处理
- [ATL/WTL]_[初级]_[关于CEdit不识别WM_KEYDOWN的问题]
- 关于WM_ERASEBKGND和WM_PAINT的深刻理解
- 关于WM_Paint 消息解析
- [ATL/WTL]_[初级]_[关于CEdit不识别WM_KEYDOWN的问题]
- 关于模态/非模态对话框不响应菜单的UPDATE_COMMAND_UI消息(对对WM_INITMENUPOPUP消息的处理)
- 关于采用默认方式处理WM_NCLBUTTONDOWN消息而“无法”产生WM_NCLBUTTONUP消息的问题
- 关于wmsys.wm_concat列超出4000处理
- 关于WM_ERASEBKGND和WM_PAINT的深刻理解
- 关于win32中响应WM_PAINT
- 关于WM_PAINT消息
- 关于WM_CTLCOLOREDIT的处理的一些问题
- TWinControl、TCustomControl和TGraphicControl对WM_PAINT消息的三种不同处理(虚函数的特点就是升升降降)
- 关于WM_PAINT
- WTL CButtonT 处理WM_DRAWITEM OwnerDraw自绘总结