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. Clearing client window

Clearing client window

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
5 Posts 3 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.
  • K Offline
    K Offline
    Kwanalouie
    wrote on last edited by
    #1

    Using Visual C++ 6.0 MFC in SDI application Under certain conditions I want my OnDraw routine to display a blank window, instead of what was previously drawn there. When I use the InvalidateRect(0) function, the OnDraw gets called, but I am looking for some window function that will clear everything. How do I do that? Thanks

    N R 2 Replies Last reply
    0
    • K Kwanalouie

      Using Visual C++ 6.0 MFC in SDI application Under certain conditions I want my OnDraw routine to display a blank window, instead of what was previously drawn there. When I use the InvalidateRect(0) function, the OnDraw gets called, but I am looking for some window function that will clear everything. How do I do that? Thanks

      N Offline
      N Offline
      Nelek
      wrote on last edited by
      #2

      Why don't you put a flag in your OnDraw ()?

      OnDraw ()
      {
      if (bBlank) //Nothing has to be drawn
      return;

      Your Drawing code...
      

      }

      and bBlank = TRUE or FALSE as you need the blank window or not

      Regards. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson Rating helpfull answers is nice, but saying thanks can be even nicer.

      K 1 Reply Last reply
      0
      • N Nelek

        Why don't you put a flag in your OnDraw ()?

        OnDraw ()
        {
        if (bBlank) //Nothing has to be drawn
        return;

        Your Drawing code...
        

        }

        and bBlank = TRUE or FALSE as you need the blank window or not

        Regards. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson Rating helpfull answers is nice, but saying thanks can be even nicer.

        K Offline
        K Offline
        Kwanalouie
        wrote on last edited by
        #3

        The problem was that I would set a flag for my OnDraw routine to do as you suggested, but in the function that set that flag I simply did flag = NOTDRAW; Invalidate(0); When I did this, with the OnDraw routine simply returning when it saw that flag, the old info in the client window would not be erased. When I changed things to Invalidate(0); flag = NOTDRAW; Invalidate(0); in the function that set the flag, then the old info in the client window would get erased. So I'm confused as to what is happening with the Invalidate(0) function.

        N 1 Reply Last reply
        0
        • K Kwanalouie

          The problem was that I would set a flag for my OnDraw routine to do as you suggested, but in the function that set that flag I simply did flag = NOTDRAW; Invalidate(0); When I did this, with the OnDraw routine simply returning when it saw that flag, the old info in the client window would not be erased. When I changed things to Invalidate(0); flag = NOTDRAW; Invalidate(0); in the function that set the flag, then the old info in the client window would get erased. So I'm confused as to what is happening with the Invalidate(0) function.

          N Offline
          N Offline
          Nelek
          wrote on last edited by
          #4

          I am not sure why it happens. I usually use the Invalidate () without 0 and just afterwards an UpdateWindow (). It is supposed that Invalidate triggers the update, but I got used to that when I start coding in MFC because of some tutorials I used. The only problem with this is that depending on how much info is on the screen it can make it flick a bit.

          Regards. -------- M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you “The First Rule of Program Optimization: Don't do it. The Second Rule of Program Optimization (for experts only!): Don't do it yet.” - Michael A. Jackson Rating helpfull answers is nice, but saying thanks can be even nicer.

          1 Reply Last reply
          0
          • K Kwanalouie

            Using Visual C++ 6.0 MFC in SDI application Under certain conditions I want my OnDraw routine to display a blank window, instead of what was previously drawn there. When I use the InvalidateRect(0) function, the OnDraw gets called, but I am looking for some window function that will clear everything. How do I do that? Thanks

            R Offline
            R Offline
            Ravi Bhavnani
            wrote on last edited by
            #5

            Kwanalouie wrote:

            I am looking for some window function that will clear everything

            Write a handler for WM_ERASEBKGND[^] /ravi

            My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

            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