诊断神秘WM_PAINT消息 [英] Diagnose mystery WM_PAINT message
问题描述
我有一个神秘的WM_PAINT消息被发送到窗口,没有理由我可以can。。我从一些代码发送一个WM_PAINT消息使用 -
InvalidateRgn(graphwin_hwnd,NULL,1);
SendMessage(graphwin_hwnd,WM_PAINT,0,0);
但是在执行在屏幕上绘制一些图形的后续代码后,调试器指示第二个WM_PAINT消息从某处到达。我的问题是,如何诊断是什么导致发送第二个WM_PAINT消息。
编辑:i486正确地指出不需要显式地做SendMessage()...但令我惊讶的是,即使我评论它,我仍然得到1多余的神秘WM_PAINT消息发送到我的图形窗口的处理程序,所以它不是很完全解决问题
编辑:糟糕,我错了,在注释掉SendMessage后,它似乎还有一个无关的错误,我只收到一个WM_PAINT消息...所以问题解决。您不需要发送WM_PAINT - Invalidate后自动发送。调用 UpdateWindow
强制它。可能第二个WM_PAINT是因为 InvalidateRgn
。要测试这个,请注释 SendMessage
并检查WM_PAINT。
I have a mystery WM_PAINT message being sent to a window for no reason that I can fathom. I am sending one WM_PAINT message from some code of mine using-
InvalidateRgn(graphwin_hwnd,NULL,1);
SendMessage(graphwin_hwnd,WM_PAINT,0,0);
but after executing the subsequent code that draws some graphics on the screen, the debugger indicates that a second WM_PAINT message arrives from somewhere. My question is, how can I diagnose what is causing this second WM_PAINT message to be sent.
Edit: i486 has correctly pointed out that I didn't need to explicitly do the SendMessage()... but to my surprise, even when I commented it out, I still get 1 excess mystery WM_PAINT message being sent to the handler for my graphics window, so it's not quite problem solved yet.
Edit: Oops, I was mistaken, after commenting out the SendMessage it seems I still had an unrelated bug screwing things up - but I did only get one WM_PAINT message... so problem solved.
You don't need to send WM_PAINT - it is sent automatically after Invalidate. Call UpdateWindow
to force it. Probably the second WM_PAINT is because of InvalidateRgn
. To test this, comment your SendMessage
and check for WM_PAINT.
这篇关于诊断神秘WM_PAINT消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!