Thread: How do I tell my window to repaint?

  1. #1
    Registered User
    Join Date
    Jan 2003
    Posts
    118

    How do I tell my window to repaint?

    I want my window to repaint itself over and over again, and I cant find out how to do it, can tell windows to send the WM_PAINT message over and over? or how can I do it? Thanks in advance.
    Why drink and drive when you can smoke and fly?

  2. #2
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    UpdateWindow() may be what you're looking for.
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  3. #3
    Registered User
    Join Date
    Jan 2003
    Posts
    118
    Thanks, but where would I put the loop?
    Why drink and drive when you can smoke and fly?

  4. #4
    Registered User
    Join Date
    Jul 2003
    Posts
    17
    You could also use InvalidateRect(); and put it into the loop where you query the messages

  5. #5
    Registered User
    Join Date
    Jan 2003
    Posts
    118
    What are InvalidateRect() 's parameters?
    Why drink and drive when you can smoke and fly?

  6. #6
    Registered User
    Join Date
    Jul 2003
    Posts
    17
    Code:
    BOOL InvalidateRect(
      HWND hWnd,           // put here your window handle
      CONST RECT* lpRect,  // if this is NULL the entire window gets an update
      BOOL bErase          // if this is true the background will be erased
    );
    Last edited by Onkel BeBu; 07-27-2003 at 11:03 AM.

  7. #7
    jasondoucette.com JasonD's Avatar
    Join Date
    Mar 2003
    Posts
    278
    To force a repaint, call InvalidateRect() to invalidate the portion of the window you wish to repaint (which puts a WM_PAINT message in the queue), and then immediately call UpdateWindow(), which forces the window procedure to process the WM_PAINT message.

    You could use a timer to allow this code to be run over and over again. Look into SetTimer() and KillTimer(), and processing of the WM_TIMER message.

  8. #8
    mustang benny bennyandthejets's Avatar
    Join Date
    Jul 2002
    Posts
    1,401
    Originally posted by Marcos
    What are InvalidateRect() 's parameters?
    Questions like this should be directed at MSDN. Don't waste our time.
    [email protected]
    Microsoft Visual Studio .NET 2003 Enterprise Architect
    Windows XP Pro

    Code Tags
    Programming FAQ
    Tutorials

  9. #9
    jasondoucette.com JasonD's Avatar
    Join Date
    Mar 2003
    Posts
    278
    Originally posted by bennyandthejets
    Questions like this should be directed at MSDN. Don't waste our time.
    Agreed.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WM_CAPTION causing CreateWindowEx() to fail.
    By Necrofear in forum Windows Programming
    Replies: 8
    Last Post: 04-06-2007, 08:23 AM
  2. 6 measly errors
    By beene in forum Game Programming
    Replies: 11
    Last Post: 11-14-2006, 11:06 AM
  3. Linking OpenGL in Dev-C++
    By linkofazeroth in forum Game Programming
    Replies: 4
    Last Post: 09-13-2005, 10:17 AM
  4. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  5. problem with open gl engine.
    By gell10 in forum Game Programming
    Replies: 1
    Last Post: 08-21-2003, 04:10 AM