Thread: status bar flickering

  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    49

    status bar flickering

    Hi there,

    I noticed that when I add a status bar to my applications that they flicker excessivily when I resize them. Has anyone else noticed this? I have made a rich edit control window using Windows API which did not flicker when it was resized until I added a status bar. When I add the status bar I don't get flickering until I add this line of code under the WM_SIZE switch case...
    Code:
    MoveWindow( hStatusBar, 0, 0, LOWORD(lParam), HIWORD(lParam), false );
    Is there anyway to get rid of this behavior?

  2. #2
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,868
    Handle the WM_ERASEBKGN msgs (return non zero)?
    "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

  3. #3
    Registered User
    Join Date
    Jan 2006
    Posts
    49
    That seems to work but it causes a few other issues with my window, I think I can find a work around though. I found some other materials related to this, they seem to blame common controls a lot. Here are some links in case anyone else with the same problem finds this thread...

    http://msdn2.microsoft.com/en-us/library/ms969905.aspx
    http://www.catch22.net/tuts/flicker.asp

  4. #4
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    I think you're probably over complicating things - just make sure your richedit control's bottom edge takes account of the status bar's position so both controls are not trying to draw over each other. In other words, use MoveWindow on the richedit control, too, in the parent's WM_SIZE handler to ensure its base is flush with the top edge of the status bar.

    If your controls cover the entire client area then it's probably a good idea to handle the parent's WM_ERASEBKGND message as described by Novacain or create the parent with a NULL brush since there's no point in drawing it. The WS_CLIPSIBLINGS window style may prove useful if used with overlapping child controls where you can't simply arrange them so they don't overlap.
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  5. #5
    HelpingYouHelpUsHelpUsAll
    Join Date
    Dec 2007
    Location
    In your nightmares
    Posts
    223
    MoveWindow? Here is what I used for my status bar:
    Code:
    GetClientRect(hwnd, &rcClient);
    SetWindowPos(hStatusBar, NULL, 0, rcClient.bottom-10, rcClient.right, 10, SWP_NOZORDER);
    Use this if you want the status bar to dock on to the bottom of the window. The 10 is the height of the status bar. If you are actually trying to resize the status bar itself (I haven't yet seen an approach where this might be a good solution, SetWindowPos might not be the best way. The parameters for SetWindowPos() are as follows: hwnd, hwnd, x, y, width, height, flags. Hope this helps.
    long time no C; //seige
    You miss 100% of the people you don't C;
    Code:
    if (language != LANG_C && language != LANG_CPP)
        drown(language);

  6. #6
    erstwhile
    Join Date
    Jan 2002
    Posts
    2,227
    Actually, the statusbar pretty much knows how to size itself when sent a WM_SIZE message with out need for dimensions. The richedit control needs to be sized/positioned to account for the statusbar's dimensions, specifically its height, and, while SetWindowPos is certainly a good option, MoveWindow is simpler to use. Something like:
    Code:
    case WM_SIZE:
    {
      SendMessage(hStatusbar,WM_SIZE,0,0);
      RECT rc;
      GetClientRect(hStatusbar,&rc);
      int statbar_height = rc.bottom - rc.top;
      MoveWindow(hRichedit,0,0,LOWORD(lParam),HIWORD(lParam) - statbar_height,0);
      return 0;
    }
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. beach bar (sims type game)
    By DrKillPatient in forum Game Programming
    Replies: 1
    Last Post: 03-06-2006, 01:32 PM
  2. Status bar
    By maxorator in forum Windows Programming
    Replies: 3
    Last Post: 11-06-2005, 11:45 AM
  3. Troubles with Sockets
    By cornholio in forum Windows Programming
    Replies: 6
    Last Post: 10-26-2005, 05:31 AM
  4. Disabling "Ready" & Other Auto Status Bar Updates :: MFC
    By kuphryn in forum C++ Programming
    Replies: 1
    Last Post: 04-03-2002, 08:51 PM
  5. Status bar covering parent window....by the way, thanks Ward
    By Unregistered in forum Windows Programming
    Replies: 1
    Last Post: 10-02-2001, 08:16 PM