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. UpdateWindow() vs InvalidateRect()

UpdateWindow() vs InvalidateRect()

Scheduled Pinned Locked Moved C / C++ / MFC
visual-studio
2 Posts 1 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.
  • J Offline
    J Offline
    J B 0
    wrote on last edited by
    #1

    Hi guys, Can anyone explain the differences between the following two calls:

    UpdateWindow(hWnd);
    

    and

    InvalidateRect(hWnd, NULL, FALSE);
    

    If I replace one with another, the app would be drawn differently. But I couldn't tell why by reading the MSDN docs :( Thanks alot

    J 1 Reply Last reply
    0
    • J J B 0

      Hi guys, Can anyone explain the differences between the following two calls:

      UpdateWindow(hWnd);
      

      and

      InvalidateRect(hWnd, NULL, FALSE);
      

      If I replace one with another, the app would be drawn differently. But I couldn't tell why by reading the MSDN docs :( Thanks alot

      J Offline
      J Offline
      J B 0
      wrote on last edited by
      #2

      I think I sort of know now - UpdateWindow(hWnd) only places a WM_PAINT message in the message queue, which leads to an execution of the WM_PAINT's message handler finally. If at that time the client area is all validated already, the window will not be re-painted. On the other hand, InvalidateRect(hWnd, NULL, FALSE) explicitly invalidates the client area and then sends a WM_PAINT message. This makes sure the window will always be re-painted when the WM_PAINT message handler reaches its time. It does two things instead of just one. Please correct me if I am wrong here. Thanks

      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