您的位置:首页 > 大数据 > 人工智能

关于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(也只能查看其代码了,因为没有文档的),发现其代码是这样写的:

// 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的话也只能这样,摸着石头过河。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: