简体   繁体   English

诊断神秘的WM_PAINT消息

[英]Diagnose mystery WM_PAINT message

I have a mystery WM_PAINT message being sent to a window for no reason that I can fathom. 我有一个神秘的WM_PAINT消息正无缘无故地发送到窗口。 I am sending one WM_PAINT message from some code of mine using- 我正在使用以下代码从我的一些代码发送一条WM_PAINT消息:

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. 但是,在执行了在屏幕上绘制一些图形的后续代码之后,调试器指示第二条WM_PAINT消息从某处到达。 My question is, how can I diagnose what is causing this second WM_PAINT message to be sent. 我的问题是,如何诊断导致此第二个WM_PAINT消息发送的原因。

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. 编辑: i486已正确指出我不需要显式执行SendMessage()...但令我惊讶的是,即使我将其注释掉,我仍然收到1个多余的神秘WM_PAINT消息,该消息已发送给我的处理程序图形窗口,因此还不能完全解决问题。

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. 编辑:糟糕,在注释掉SendMessage之后,我似乎仍然有一个无关的错误将事情搞砸了-但是我只收到一条WM_PAINT消息...因此问题得以解决。

You don't need to send WM_PAINT - it is sent automatically after Invalidate. 您不需要发送WM_PAINT-无效后会自动发送。 Call UpdateWindow to force it. 调用UpdateWindow强制它。 Probably the second WM_PAINT is because of InvalidateRgn . 第二个WM_PAINT可能是由于InvalidateRgn To test this, comment your SendMessage and check for WM_PAINT. 要对此进行测试,请注释您的SendMessage并检查WM_PAINT。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM