Reputation: 7937
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.
Upvotes: 1
Views: 394
Reputation: 6563
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.
Upvotes: 1