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. CJBK_View::OnDraw(CDC* p_DC)

CJBK_View::OnDraw(CDC* p_DC)

Scheduled Pinned Locked Moved C / C++ / MFC
graphicsquestion
4 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.
  • B Offline
    B Offline
    BarryPearlman
    wrote on last edited by
    #1

    I am trying to use the "OnDraw" message to respond to the left mouse button click. The "Button Up" triggers ->Invalidate(TRUE); and -> UpdateWindow(); which then calls "OnDraw". Once "OnDraw" is called, a long series of graphics functions are used to draw what I want to display, using the DC supplied by "OnDraw". This all works and draws what I want, however: "OnDraw" seems to be called 3 consecutive times, each with a different DC for the same hwnd. This causes the graphics (which don't change) to be calculated and drawn 3 times producing an annoying flicker and waste of application processing time. Is there a way to get just one call to "OnDraw"? WM_PAINT seems to also be sent 3 times. Any suggestions to different methods or approaches will be welcome. Thanks and Happy Thanksgiving to those who celebrate. Barry :confused:

    L B 2 Replies Last reply
    0
    • B BarryPearlman

      I am trying to use the "OnDraw" message to respond to the left mouse button click. The "Button Up" triggers ->Invalidate(TRUE); and -> UpdateWindow(); which then calls "OnDraw". Once "OnDraw" is called, a long series of graphics functions are used to draw what I want to display, using the DC supplied by "OnDraw". This all works and draws what I want, however: "OnDraw" seems to be called 3 consecutive times, each with a different DC for the same hwnd. This causes the graphics (which don't change) to be calculated and drawn 3 times producing an annoying flicker and waste of application processing time. Is there a way to get just one call to "OnDraw"? WM_PAINT seems to also be sent 3 times. Any suggestions to different methods or approaches will be welcome. Thanks and Happy Thanksgiving to those who celebrate. Barry :confused:

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

      You should not be calling UpdateWindow after Invalidate. The Invalidate call is enough to trigger the redrawing.

      Veni, vidi, abiit domum

      1 Reply Last reply
      0
      • B BarryPearlman

        I am trying to use the "OnDraw" message to respond to the left mouse button click. The "Button Up" triggers ->Invalidate(TRUE); and -> UpdateWindow(); which then calls "OnDraw". Once "OnDraw" is called, a long series of graphics functions are used to draw what I want to display, using the DC supplied by "OnDraw". This all works and draws what I want, however: "OnDraw" seems to be called 3 consecutive times, each with a different DC for the same hwnd. This causes the graphics (which don't change) to be calculated and drawn 3 times producing an annoying flicker and waste of application processing time. Is there a way to get just one call to "OnDraw"? WM_PAINT seems to also be sent 3 times. Any suggestions to different methods or approaches will be welcome. Thanks and Happy Thanksgiving to those who celebrate. Barry :confused:

        B Offline
        B Offline
        BarryPearlman
        wrote on last edited by
        #3

        This solved the problem. Thanks. Just under what conditions would one call ->UpdateWindow?:cool:

        Barry

        L 1 Reply Last reply
        0
        • B BarryPearlman

          This solved the problem. Thanks. Just under what conditions would one call ->UpdateWindow?:cool:

          Barry

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

          The documentation[^] explains what the function does, and suggests that it should be called immediately after a Window is created. This has always been my understanding, and the remainder of the time you just use InvalidateRect or InvalidateRgn to queue the redrawing messages.

          Veni, vidi, abiit domum

          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