Thread: Flicking toolbars on resize

  1. #1
    Registered User
    Join Date
    Jun 2003

    Flicking toolbars on resize

    VisualC++ / No MFC.

    When the window is resized, the toolbar at the top flickers horribly - is there a way to fix this? It happens whether or not I pass the WM_SIZE through to the toolbar.

    The toolbar was setup like this:

    hToolbar = CreateToolbarEx (hWnd, WS_VISIBLE | WS_CHILD | WS_BORDER | TBSTYLE_TOOLTIPS, IDM_TOOLBAR,	64, hInst, 
    IDB_TOOLBAR_BITMAP, TBButtons, NumTBButtons, 16, 16, 16, 16, sizeof(TBBUTTON));
    and my WM_PAINT event currently does nothing but BeginPaint / EndPaint.

  2. #2
    Join Date
    Jan 2002
    If the whole of your main window's client area is covered with controls then you can eliminate flicker by registering that window without the CS_HREDRAW or CS_VREDRAW styles (see style parameter of WNDCLASSEX struct).

    Alternatively, handle the WM_ERASBKGROUND of the parent and make sure that the toolbar 'background' is not filled. This will not work with toolbars with transparent buttons, though (TBSTYLE_FLAT style).
    CProgramming FAQ
    Caution: this person may be a carrier of the misinformation virus.

  3. #3 JasonD's Avatar
    Join Date
    Mar 2003
    Another note is that the background is only drawn over the window during a WM_PAINT message when you have a background brush set (and when you have those styles that were mentioned in the previous post, the entire client area becomes invalid during resizing, causing it all to painted with the background brush). So you can set the background brush to NULL, and handle the re-drawing of the entire background yourself. I guess this would be the same as handling the WM_ERASBKGROUND message - it kind of makes having a background brush pointless.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. png Image Resize
    By bhupesh.kec in forum C Programming
    Replies: 3
    Last Post: 12-06-2007, 07:52 AM
  2. Resize Dialog Box via Code :: MFC
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 10-27-2002, 11:00 PM
  3. Disable resize events and window moves
    By cozman in forum Windows Programming
    Replies: 4
    Last Post: 06-24-2002, 09:12 AM
  4. Disable Resize Window :: MFC
    By kuphryn in forum Windows Programming
    Replies: 2
    Last Post: 04-07-2002, 07:26 PM
  5. Toolbars ... Rebars... whatever!... ...
    By Unregistered in forum Windows Programming
    Replies: 2
    Last Post: 11-19-2001, 08:44 PM