Click to See Complete Forum and Search --> : Can't force window repaint?


Zeddy2
October 1st, 2005, 01:53 PM
Hi guys,

I am to be king of odd problems!

I want MY application to force ANOTHER process window to repaint. I figure this should be easy!

I try all of these:

InvalidateRect(hwnd, NULL, TRUE);
RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_ERASENOW | RDW_UPDATENOW | RDW_INTERNALPAINT);
UpdateWindow(hwnd);
SetWindowPos(hwnd, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER);

None force repaint! But, if I click in process window, then set focus somewhere else (eg, click on task bar), then click back in process window, repaint happens.

Any idea?

Thanks!

rxbagain
October 1st, 2005, 11:53 PM
Try to send the WM_PAINT message.

Hope it will help you

olivthill
October 2nd, 2005, 02:59 AM
InvalidateRect() and sending a WM_PAINT message are equivalent methods. I suppose the problem is that you program does not have the time to read the message queue, because it is in a single thread and you might not let Windows breath. But I'm not giving a solution because it is not always easy to do give back the hand to Windows in the middle of a routine. It depends on the design of your algorithm.

Zeddy2
October 2nd, 2005, 07:07 AM
Try to send the WM_PAINT message.

Hope it will help you

No you must not do this. Application must never sent WM_PAINT to another process, MSDN says.

I suppose the problem is that you program does not have the time to read the message queue, because it is in a single thread and you might not let Windows breath.

No, this is not problem either. I have 2 buttons in app. Click button 1, it draws rubbish on another process hwnd. Click button 2, it sends InvalidateRect/UpdateWindow etc all code I pasted to that process hwnd.

I click button 1, it draws fine. I click button 2, nothing. I exit my app, nothing. I do anything else, nothing. Window in other process is only repainted when I clcik on it & give focus or force repaint by doing something.

It is strange...