Timer and GDI+ Window Update

  • Thread starter Thread starter Rohit
  • Start date Start date
R

Rohit

I have a timer object that calls UpdateWindow(). The WM_TIMER message is
processed in the main Win32 message loop for the window. However, when I run
the app, the image doesn't get updated (there is some animation that's
supposed to happen). However, if I constantly resize the window, the
animation happens as expected (but I want the animation to happen without me
having to mess with the window size). I verified that the timer is firing
correctly. What is the problem?
 
Rohit said:
I have a timer object that calls UpdateWindow(). The WM_TIMER message is
processed in the main Win32 message loop for the window. However, when I
run
the app, the image doesn't get updated (there is some animation that's
supposed to happen). However, if I constantly resize the window, the
animation happens as expected (but I want the animation to happen without
me
having to mess with the window size). I verified that the timer is firing
correctly. What is the problem?

Before updating the window, you also need to invalidate all or a portion of
the window.

See InvalidateRect(), etc.

Mark
 
Thanks. That worked.

Now the problem is that there is too much flickering. Is there a way to
avoid that, or do I have to recode it in DirectX?
 
Rohit said:
Thanks. That worked.

Now the problem is that there is too much flickering. Is there a way to
avoid that, or do I have to recode it in DirectX?


You could invalidate only regions of the window that need redrawing...that
will reduce flicker.

Using a transparent background and doing all foreground drawing helps a lot.

You could use an offscreen buffer (double-buffering) to draw to and blt the
entire buffer to the screen when necessary.

DirectX is certainly a solution, but a different approach than GDI.

I personally do a lot of multimedia rendering, and find double buffering
works great for me, both with GDI/GDI+ and WPF.

Mark
 
Can you describe how to use double-buffering to draw the scene to an off
screen buffer and blt the entire thing in GDI+? Or could you point me to
some example code on the Internet?

In Outlook 2003, when a new email arrives, the notification fades in and
out. This is most likely implemented using GDI+ and altering the
transparency factor. But there is not flicker. Do they use double-buffering
in this case?
 
I found some code which draws the scene to a bitmap and then displays the
bitmap. However, the API calls did not take the device context as an
argument; consequently, nothing displayed in the window. Do you know how to
actually make the bitmap show up in the window?

BTW, I am programming in straight Win32 because I hate MFC and .NET.
 
I figured it out. No more flickering - yay.

Rohit said:
I found some code which draws the scene to a bitmap and then displays the
bitmap. However, the API calls did not take the device context as an
argument; consequently, nothing displayed in the window. Do you know how to
actually make the bitmap show up in the window?

BTW, I am programming in straight Win32 because I hate MFC and .NET.
 
Back
Top