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. Window Refresh problem

Window Refresh problem

Scheduled Pinned Locked Moved C / C++ / MFC
help
4 Posts 4 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.
  • M Offline
    M Offline
    manoharbalu
    wrote on last edited by
    #1

    I created a class derived from CStatic control. I used this class to create a control similar to a clock control in which a needle rotated continously to show some value. I used onPaint to draw the control's face and a timer to change the position of the needle. In the onTimer function, I used the CDC object to change the position of the line and I am calling the Invalidate function. I used this control by adding a static control in a dialog in a application. and then created a member variable for the static control and changed member to be an object of my class. Now when I run the application, my control works fine. But a small blink seems to appear when the needle changes position. If anybody has suggestions to avoid the blink, Please tell me. Thanks in Advance, Mohan

    S S A 3 Replies Last reply
    0
    • M manoharbalu

      I created a class derived from CStatic control. I used this class to create a control similar to a clock control in which a needle rotated continously to show some value. I used onPaint to draw the control's face and a timer to change the position of the needle. In the onTimer function, I used the CDC object to change the position of the line and I am calling the Invalidate function. I used this control by adding a static control in a dialog in a application. and then created a member variable for the static control and changed member to be an object of my class. Now when I run the application, my control works fine. But a small blink seems to appear when the needle changes position. If anybody has suggestions to avoid the blink, Please tell me. Thanks in Advance, Mohan

      S Offline
      S Offline
      SandipG
      wrote on last edited by
      #2

      manohar_balu wrote:

      I used the CDC object to change the position of the line and I am calling the Invalidate function.

      If you are already changing the line position on DC why call invalidate again. Or else dont change just call Invalidate in Timer.

      Regards, Sandip.

      1 Reply Last reply
      0
      • M manoharbalu

        I created a class derived from CStatic control. I used this class to create a control similar to a clock control in which a needle rotated continously to show some value. I used onPaint to draw the control's face and a timer to change the position of the needle. In the onTimer function, I used the CDC object to change the position of the line and I am calling the Invalidate function. I used this control by adding a static control in a dialog in a application. and then created a member variable for the static control and changed member to be an object of my class. Now when I run the application, my control works fine. But a small blink seems to appear when the needle changes position. If anybody has suggestions to avoid the blink, Please tell me. Thanks in Advance, Mohan

        S Offline
        S Offline
        sudhir_Kumar
        wrote on last edited by
        #3

        This is because it is getting painted twice for every WM_PAINT it receives. The problem is the WM_ERASEBKGND message, which is sent every time we call BeginPaint. This isn't a problem really - Windows is doing us a favour, because the default action for WM_ERASEBKGND is to draw a nice window background for us (using the window's default background brush), which we can then paint on top of in the WM_PAINT handler. However, our WM_PAINT handler also draws the control's background, so there is no point in this happening twice. Therefore, we need to prevent the default WM_ERASEBKGND behaviour from happending. As usual, there are a number of ways to do this. Set the window's background brush to NULL. (Set the hbrBackground member of the WNDCLASS structure to zero when you register the window class). Return non-zero in the WM_ERASEBKGND message handler.

        -@SuDhIrKuMaR@-

        1 Reply Last reply
        0
        • M manoharbalu

          I created a class derived from CStatic control. I used this class to create a control similar to a clock control in which a needle rotated continously to show some value. I used onPaint to draw the control's face and a timer to change the position of the needle. In the onTimer function, I used the CDC object to change the position of the line and I am calling the Invalidate function. I used this control by adding a static control in a dialog in a application. and then created a member variable for the static control and changed member to be an object of my class. Now when I run the application, my control works fine. But a small blink seems to appear when the needle changes position. If anybody has suggestions to avoid the blink, Please tell me. Thanks in Advance, Mohan

          A Offline
          A Offline
          Alan Balkany
          wrote on last edited by
          #4

          You can use double buffering. Draw the clock on an in-memory bitmap, and in your OnPaint () handler just BitBlt the bitmap to the OnPaint CDC.

          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