repainting a window

This is a discussion on repainting a window within the Windows Programming forums, part of the Platform Specific Boards category; I'm confused a little about system of repainting in Windows. If I send window a WM_PAINT message, it usally does ...

  1. #1
    Registered User larry's Avatar
    Join Date
    Sep 2001
    Posts
    96

    repainting a window

    I'm confused a little about system of repainting in Windows. If I send window a WM_PAINT message, it usally does nothing, because the update rectangle is empty. So I use InvalidateRect function to set the update rectangle. But my program also draws in the client area some graphics and on slow computers I could experience "flickering" effect on the toolbar. I found out that this is because the update rectangle is in such cases set to whole window. I found in help that you can use CS_CLIPSIBLINGS (or something like this) class style to let Windows remove all child windows from the update rectangle. But when I use it, buttons on toolbar stay pressed when I click them.
    All I need to do is a program that redraws everything except child windows (I have a toolbar and a statusbar) everytime I send a WM_PAINT message to the main window and that redraws toolbar or statusbar whenever it's needed (user clicks a button on the toolbar or statusbar text changed).
    Any solution?
    Last edited by larry; 01-16-2002 at 11:22 AM.
    Please excuse my poor english...

  2. #2
    Unregistered
    Guest
    use the ws_clipchildren style for the parent of the toolbar.

    When you use InvalidateRect(hwnd,&rc,0 or 1) make sure that the update rect does NOT include the toolbar ( you can always invalidate that separately, if required).

    Apparently flicker isn't a problem with winxp due to the doubl-buffering introduced with gdi+.

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    421
    you shouldn't really send the WM_PAINT message explicitly.. use UpdateWindow() instead.

    U.
    Quidquid latine dictum sit, altum sonatur.
    Whatever is said in Latin sounds profound.

  4. #4
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    Try,

    return TRUE for WM_ERASEBKGND msg to stop flicker.

    use GetUpdateRect() in the paint function before calling BeginPaint()
    Code:
    GetUpdateRect(hWnd, &theRect, 0);
    if (IsRectEmpty(&theRect))
    {
        //set the area here to repaint if not what you want or
        GetClientRect(hWnd,&theRect);
    }
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

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, 10:06 AM
  3. My Window Class
    By Epo in forum Game Programming
    Replies: 2
    Last Post: 07-10-2005, 02:33 PM
  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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21