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. Windows API
  4. Problems redrawing after minimize/restore

Problems redrawing after minimize/restore

Scheduled Pinned Locked Moved Windows API
graphicshelpquestionannouncement
4 Posts 2 Posters 13 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.
  • D Offline
    D Offline
    Derell Licht
    wrote on last edited by
    #1

    I have a dialog-based application, and I use a portion of the dialog for drawing some graphics. I have a problem when I minimize and then restore the dialog... I handle WM_SIZE (wParam == SIZE_RESTORED) to redraw my graphics, but this doesn't work because WM_PAINT occurs afterwards and redraws the entire dialog, leaving my graphics area blank. I tried moving my update function to WM_PAINT, but even that doesn't work, because the system redraws the dialog after my handler returns!! How is this problem typically solved?? For now, I'm going to start a 50msec timer in WM_SIZE, and redraw my graphics in that, then stop the timer. I've used this trick before, and it works well enough, but I know that's not how this is supposed to be done!!

    J 1 Reply Last reply
    0
    • D Derell Licht

      I have a dialog-based application, and I use a portion of the dialog for drawing some graphics. I have a problem when I minimize and then restore the dialog... I handle WM_SIZE (wParam == SIZE_RESTORED) to redraw my graphics, but this doesn't work because WM_PAINT occurs afterwards and redraws the entire dialog, leaving my graphics area blank. I tried moving my update function to WM_PAINT, but even that doesn't work, because the system redraws the dialog after my handler returns!! How is this problem typically solved?? For now, I'm going to start a 50msec timer in WM_SIZE, and redraw my graphics in that, then stop the timer. I've used this trick before, and it works well enough, but I know that's not how this is supposed to be done!!

      J Offline
      J Offline
      Jochen Arndt
      wrote on last edited by
      #2

      Within your WM_PAINT handler, call the default handler first to let the system draw the dialog. Then call your own routine to draw the graphics. Note that your handler must return zero to indicate that the message has been processed. You may also draw your graphics by handling the WM_ERASEBKGND message using the same method (call default handler first and return zero EDIT: nonzero here).

      D 1 Reply Last reply
      0
      • J Jochen Arndt

        Within your WM_PAINT handler, call the default handler first to let the system draw the dialog. Then call your own routine to draw the graphics. Note that your handler must return zero to indicate that the message has been processed. You may also draw your graphics by handling the WM_ERASEBKGND message using the same method (call default handler first and return zero EDIT: nonzero here).

        D Offline
        D Offline
        Derell Licht
        wrote on last edited by
        #3

        How do I call the default handler?? Do I do the same as with a subclassed control: return CallWindowProc (lpfnEditWndProc, hWndEdit, msg, wParam, lParam); At this point, this is not a subclassed function.

        J 1 Reply Last reply
        0
        • D Derell Licht

          How do I call the default handler?? Do I do the same as with a subclassed control: return CallWindowProc (lpfnEditWndProc, hWndEdit, msg, wParam, lParam); At this point, this is not a subclassed function.

          J Offline
          J Offline
          Jochen Arndt
          wrote on last edited by
          #4

          To call the default handler, call DefWindowProc() when using the Windows API. When using MFC, override OnPaint() or OnEraseBkgnd() and call the base class function first (e.g. CDialog::OnEraseBkgnd()). Note that there is an error in my previous post (I will edit it): WM_ERASEBKGND handlers must return nonzero when the background has been erased. You may also just get the return value of the default function and return that.

          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