Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Owner drawn button flicker hell

Owner drawn button flicker hell

Scheduled Pinned Locked Moved C / C++ / MFC
c++comquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    Christian Graus
    wrote on last edited by
    #1

    I'm not using MFC, and I'm storing bitmaps inside my own button classes, which encapsulate the HWND of the button. If I respond to the WM_DRAWITEM message, and draw my buttons, they flicker like crazy if the window is being resized ( and they are moved ). The ones that stay put also flicker as they are redrawn. I've been trying to get a wndproc happening to subclass the buttons, but that seems not to want to work. Does anyone have any other suggestions ? Christian After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001

    Sonork ID 100.10002:MeanManOz

    I live in Bob's HungOut now

    R 1 Reply Last reply
    0
    • C Christian Graus

      I'm not using MFC, and I'm storing bitmaps inside my own button classes, which encapsulate the HWND of the button. If I respond to the WM_DRAWITEM message, and draw my buttons, they flicker like crazy if the window is being resized ( and they are moved ). The ones that stay put also flicker as they are redrawn. I've been trying to get a wndproc happening to subclass the buttons, but that seems not to want to work. Does anyone have any other suggestions ? Christian After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001

      Sonork ID 100.10002:MeanManOz

      I live in Bob's HungOut now

      R Offline
      R Offline
      Rick Dangerous
      wrote on last edited by
      #2

      Whenever your window is being resized, your main window is receiving a WM_ERASEBKGND message. This message by default erases all the controls on the window which then need to be redrawn. This is bad for flicker. One was around this would be to use the following routine to only fill in that windows area by excluding the areas of the controls on the window so they are not erased:

      int dont_erase_indexes[] =
      {
      IDC_DPAS_LAMP,
      IDC_INSTRUMENT_TYPE,
      IDC_LABEL1,
      IDC_LABEL2,
      IDC_DESTINATION,
      IDC_CURRENT_STATUS,
      IDC_LOG,
      IDC_GRAPH,
      IDC_DOWNLOAD_STATUS,
      IDC_DOWNLOAD_PROGRESS,
      ID_AUTO_LOAD,
      IDC_UPLOAD_ASSAYS,
      IDC_AUTO_UPLOAD,
      IDC_BROWSE_FOR_FOLDER
      } ;

      BOOL CYourWindow::OnEraseBkgnd(CDC* pDC)
      {
      static int dont_erase_indexes[] =
      {// this is a list of the ID's of the controls on the parent window
      IDC_DPAS_LAMP,
      IDC_INSTRUMENT_TYPE,
      IDC_LABEL1,
      IDC_LABEL2,
      IDC_DESTINATION,
      IDC_CURRENT_STATUS,
      IDC_LOG,
      IDC_GRAPH,
      IDC_DOWNLOAD_STATUS,
      IDC_DOWNLOAD_PROGRESS,
      ID_AUTO_LOAD,
      IDC_UPLOAD_ASSAYS,
      IDC_AUTO_UPLOAD,
      IDC_BROWSE_FOR_FOLDER
      } ;
      CRect clip ;
      pDC->SaveDC() ;
      for (int i = 0 ; i < sizeof(dont_erase_indexes) / sizeof(int) ; i++)
      {
      GetDlgItem(dont_erase_indexes[i])->GetWindowRect(&clip); // get rect of the control
      ScreenToClient(&clip);
      pDC->ExcludeClipRect(&clip);
      }
      pDC->GetClipBox(&clip);
      pDC->FillSolidRect(clip, GetSysColor(COLOR_BTNFACE));
      pDC->RestoreDC(-1) ;
      return FALSE;
      }

      Hope this helps out Roger Bin Allen :-D

      C 1 Reply Last reply
      0
      • R Rick Dangerous

        Whenever your window is being resized, your main window is receiving a WM_ERASEBKGND message. This message by default erases all the controls on the window which then need to be redrawn. This is bad for flicker. One was around this would be to use the following routine to only fill in that windows area by excluding the areas of the controls on the window so they are not erased:

        int dont_erase_indexes[] =
        {
        IDC_DPAS_LAMP,
        IDC_INSTRUMENT_TYPE,
        IDC_LABEL1,
        IDC_LABEL2,
        IDC_DESTINATION,
        IDC_CURRENT_STATUS,
        IDC_LOG,
        IDC_GRAPH,
        IDC_DOWNLOAD_STATUS,
        IDC_DOWNLOAD_PROGRESS,
        ID_AUTO_LOAD,
        IDC_UPLOAD_ASSAYS,
        IDC_AUTO_UPLOAD,
        IDC_BROWSE_FOR_FOLDER
        } ;

        BOOL CYourWindow::OnEraseBkgnd(CDC* pDC)
        {
        static int dont_erase_indexes[] =
        {// this is a list of the ID's of the controls on the parent window
        IDC_DPAS_LAMP,
        IDC_INSTRUMENT_TYPE,
        IDC_LABEL1,
        IDC_LABEL2,
        IDC_DESTINATION,
        IDC_CURRENT_STATUS,
        IDC_LOG,
        IDC_GRAPH,
        IDC_DOWNLOAD_STATUS,
        IDC_DOWNLOAD_PROGRESS,
        ID_AUTO_LOAD,
        IDC_UPLOAD_ASSAYS,
        IDC_AUTO_UPLOAD,
        IDC_BROWSE_FOR_FOLDER
        } ;
        CRect clip ;
        pDC->SaveDC() ;
        for (int i = 0 ; i < sizeof(dont_erase_indexes) / sizeof(int) ; i++)
        {
        GetDlgItem(dont_erase_indexes[i])->GetWindowRect(&clip); // get rect of the control
        ScreenToClient(&clip);
        pDC->ExcludeClipRect(&clip);
        }
        pDC->GetClipBox(&clip);
        pDC->FillSolidRect(clip, GetSysColor(COLOR_BTNFACE));
        pDC->RestoreDC(-1) ;
        return FALSE;
        }

        Hope this helps out Roger Bin Allen :-D

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        Hey, cool. I did not know about this stuff, thank you *very* much. Christian After all, there's nothing wrong with an elite as long as I'm allowed to be part of it!! - Mike Burston Oct 23, 2001

        Sonork ID 100.10002:MeanManOz

        I live in Bob's HungOut now

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups