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