本文转自:http://blog.csdn.net/kesummer/article/details/5937053
WTL8.0中的atlcrack.h对窗口消息进行了解码,因为windows消息一般由wParam和lParam传递,这样使用起来不方便。但对WM_PAINT解码成OnPaint(HDC hDC),hDC一直都为NULL,查看了atlcrack.h(也只能查看其代码了,因为没有文档的),发现其代码是这样写的:
//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.