CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Sep 2005
    Posts
    62

    Can't force window repaint?

    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:

    Code:
    		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!

  2. #2
    Join Date
    Apr 2003
    Posts
    1,755

    Smile Re: Can't force window repaint?

    Try to send the WM_PAINT message.

    Hope it will help you

  3. #3
    Join Date
    Jun 2005
    Posts
    1,255

    Re: Can't force window repaint?

    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.

  4. #4
    Join Date
    Sep 2005
    Posts
    62

    Re: Can't force window repaint?

    Quote Originally Posted by rxbagain
    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...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured