WM_PAINT 消息 太诡异了
1 我的鼠标在窗口上移动 怎么会产生 WM_PAINT 消息?
而已要大范围移动且要移动久一点才会产生一个 WM_PAINT 。怪异啊
2, 我使用了 InvalidateRect (hwnd, NULL, false); 让BeginPaint 执行后不会删除背景, 于是我把一个其他程序的小窗口移动到我写的程序窗口 再移开以次产生一个 无效区域
,然后按预料的 程序发送了一个WM_PAINT 并且最后BeginPaint 执行 也没有删除背景
但是但我 重复
“把一个其他程序的小窗口移动到我写的程序窗口 再移开以次产生一个 无效区域”
两次 ,事情就变了 BeginPaint 执行后 把背景删除了 实在是太诡异了~~~~~
PAINTSTRUCT ps;
char szChar[20];
char szChar1[20];
char szChar2[20];
char szChar3[20];
char szChar4[20];
static int tmp=0;
char szChar5[10];
RECT rect1,rect,rect2;
case WM_PAINT:
HDC hDC;
GetUpdateRect(hwnd,&rect1,false);
sprintf(szChar1, "top is %d ",rect1.top);
sprintf(szChar2, "botn is %d ",rect1.bottom);
sprintf(szChar3, "left is %d ",rect1.left);
sprintf(szChar4, "right is %d ",rect1.right);
InvalidateRect (hwnd, NULL, false);
;hDC=BeginPaint(hwnd,&ps);
GetClientRect (hwnd, &rect) ;
tmp++;
sprintf(szChar5, "%d ",tmp);
DrawText (ps.hdc, TEXT (szChar5), -1, &rect,DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;
TextOut(hDC,0,i,szChar1,strlen(szChar1));
TextOut(hDC,0,i+100,szChar2,strlen(szChar2));
TextOut(hDC,0,i+200,szChar3,strlen(szChar3));
TextOut(hDC,0,i+300,szChar4,strlen(szChar4));
EndPaint(hwnd,&ps);
break;
[解决办法]
你可以用spy++看看你那里发生了些什么,不过这可能需要一些技巧:)