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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to force the control to redraw?

How to force the control to redraw?

Scheduled Pinned Locked Moved C / C++ / MFC
c++graphicshelptutorialquestion
3 Posts 3 Posters 1 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.
  • Y Offline
    Y Offline
    ytod
    wrote on last edited by
    #1

    Hi everyone: I wrote a MFC dialog-based program. My program need to use the GDI function FillRect to fill teh dialog in some specified color. But there are two buttons in that dialog, my problem is how to force them to be redrawn after I filled the dialog? Since the action of the function FillRect would fill whole dialog with my color and these 2 buttons would also be covered. Can somebody tell me how to do? I have no much time on this project. Thanks!

    L J 2 Replies Last reply
    0
    • Y ytod

      Hi everyone: I wrote a MFC dialog-based program. My program need to use the GDI function FillRect to fill teh dialog in some specified color. But there are two buttons in that dialog, my problem is how to force them to be redrawn after I filled the dialog? Since the action of the function FillRect would fill whole dialog with my color and these 2 buttons would also be covered. Can somebody tell me how to do? I have no much time on this project. Thanks!

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      Invalidate() or InvalidateRect()

      1 Reply Last reply
      0
      • Y ytod

        Hi everyone: I wrote a MFC dialog-based program. My program need to use the GDI function FillRect to fill teh dialog in some specified color. But there are two buttons in that dialog, my problem is how to force them to be redrawn after I filled the dialog? Since the action of the function FillRect would fill whole dialog with my color and these 2 buttons would also be covered. Can somebody tell me how to do? I have no much time on this project. Thanks!

        J Offline
        J Offline
        John R Shaw
        wrote on last edited by
        #3

        Well if that is all it needs to do then just override OnEraseBkgnd() to fill the background.

        // IN HEADER
        class CMyDialog : public CDialog
        {
        //.......
        int m_FillBrushIndex;
        CBrush m_FillBrush[2];
        //.......
        };

        // IN CPP FILE
        afx_msg BOOL CMyDialogLLOnEraseBkgnd( CDC* pDC )
        {
        //...
        pDC->FillRect(&rect,&m_FillBrush[m_FillBrushIndex]);
        //...
        return TRUE;
        }

        void CLineInfoDlg::OnButton1()
        {
        //...
        m_FillBrushIndex = 0;
        InvalidateWindow();
        }

        void CLineInfoDlg::OnButton2()
        {
        //...
        m_FillBrushIndex = 1;
        InvalidateWindow();
        }

        INTP "The more help VB provides VB programmers, the more miserable your life as a C++ programmer becomes." Andrew W. Troelsen

        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