473,399 Members | 3,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Timer and GDI+ Window Update

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?
Jul 30 '08 #1
7 2511
"Rohit" <Ro***@discussions.microsoft.comwrote in message
news:7F**********************************@microsof t.com...
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

--
Mark Salsbery
Microsoft MVP - Visual C++

Jul 30 '08 #2
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?

"Mark Salsbery [MVP]" wrote:
"Rohit" <Ro***@discussions.microsoft.comwrote in message
news:7F**********************************@microsof t.com...
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

--
Mark Salsbery
Microsoft MVP - Visual C++

Aug 1 '08 #3
"Rohit" <Ro***@discussions.microsoft.comwrote in message
news:64**********************************@microsof t.com...
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

--
Mark Salsbery
Microsoft MVP - Visual C++

>
"Mark Salsbery [MVP]" wrote:
>"Rohit" <Ro***@discussions.microsoft.comwrote in message
news:7F**********************************@microso ft.com...
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

--
Mark Salsbery
Microsoft MVP - Visual C++

Aug 1 '08 #4
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?

"Mark Salsbery [MVP]" wrote:
"Rohit" <Ro***@discussions.microsoft.comwrote in message
news:64**********************************@microsof t.com...
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

--
Mark Salsbery
Microsoft MVP - Visual C++


"Mark Salsbery [MVP]" wrote:
"Rohit" <Ro***@discussions.microsoft.comwrote in message
news:7F**********************************@microsof t.com...
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

--
Mark Salsbery
Microsoft MVP - Visual C++

Aug 2 '08 #5
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.

"Rohit" wrote:
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?

"Mark Salsbery [MVP]" wrote:
"Rohit" <Ro***@discussions.microsoft.comwrote in message
news:64**********************************@microsof t.com...
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

--
Mark Salsbery
Microsoft MVP - Visual C++

>
"Mark Salsbery [MVP]" wrote:
>
>"Rohit" <Ro***@discussions.microsoft.comwrote in message
>news:7F**********************************@microso ft.com...
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
>>
>--
>Mark Salsbery
>Microsoft MVP - Visual C++
>>
>>
Aug 2 '08 #6
I figured it out. No more flickering - yay.

"Rohit" wrote:
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.

"Rohit" wrote:
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?

"Mark Salsbery [MVP]" wrote:
"Rohit" <Ro***@discussions.microsoft.comwrote in message
news:64**********************************@microsof t.com...
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
>
--
Mark Salsbery
Microsoft MVP - Visual C++
>
>

"Mark Salsbery [MVP]" wrote:

"Rohit" <Ro***@discussions.microsoft.comwrote in message
news:7F**********************************@microsof t.com...
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
>
--
Mark Salsbery
Microsoft MVP - Visual C++
>
>
>
Aug 2 '08 #7
"Rohit" <Ro***@discussions.microsoft.comwrote in message
news:0E**********************************@microsof t.com...
I figured it out. No more flickering - yay.

Cool :-)

Cheers,
Mark

--
Mark Salsbery
Microsoft MVP - Visual C++

Aug 2 '08 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Franco Gustavo | last post by:
Hi, How can I execute 2 GDI steps without update the screen and update them togheter?. Basically I have a form and I want to change the Form Region and change the Form Location, later show...
4
by: Naveen Mukkelli | last post by:
Hi, Currently I'm using System.Threading.Timer to perform some tasks periodically, lets say every minute. How can we disable this timer(System.Threading.Timer) so that the time spent in the...
2
by: User | last post by:
Hi, What is the best way to release all resources holded by the Timer (myTimer from class System.Timers.Timer)? Is it: 1- myTimer.dispose 2- myTimer.enabled = false 3- myTimer.close
7
by: LBT | last post by:
I have a window service written using VB.NET. This window service will scan folders for file and grab the file content to be inserted to SQL Server on file detection. There are altogether 18...
5
by: Michael C# | last post by:
Hi all, I set up a System.Timers.Time in my app. The code basically just updates the screen, but since the processing performed is so CPU-intensive, I wanted to make sure it gets updated...
4
by: grayaii | last post by:
Hi, I have a simple form that handles all its paint functionality like so: this.SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.Opaque, true); And the entry point to this...
11
by: cty0000 | last post by:
I have some quiestion... I want to draw line,point,rectangles and etc... on the from So I code like this.. public update() { g = this.CreateGraphics(); g.FillRectangle(Brushes.White, x1,...
29
by: canabatz | last post by:
Hello , i got this code that works great , now i want to have it refresh every 4 seconds , where can i put the timer to do that? i realy need help!! thanx!! <script type="text/javascript">...
3
by: Steve | last post by:
Hi All I am using VB.net 2008 and use timer controls within my applications Question Does the code in a Timer control.tick event run on a different thread to the main Application thread (UI...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.