473,563 Members | 2,857 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2525
"Rohit" <Ro***@discussi ons.microsoft.c omwrote in message
news:7F******** *************** ***********@mic rosoft.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***@discussi ons.microsoft.c omwrote in message
news:7F******** *************** ***********@mic rosoft.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***@discussi ons.microsoft.c omwrote in message
news:64******** *************** ***********@mic rosoft.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...tha t
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***@discussi ons.microsoft.c omwrote in message
news:7F******* *************** ************@mi crosoft.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***@discussi ons.microsoft.c omwrote in message
news:64******** *************** ***********@mic rosoft.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...tha t
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***@discussi ons.microsoft.c omwrote in message
news:7F******** *************** ***********@mic rosoft.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***@discussi ons.microsoft.c omwrote in message
news:64******** *************** ***********@mic rosoft.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...tha t
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***@discussi ons.microsoft.c omwrote in message
>news:7F******* *************** ************@mi crosoft.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***@discussi ons.microsoft.c omwrote in message
news:64******** *************** ***********@mic rosoft.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...tha t
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***@discussi ons.microsoft.c omwrote in message
news:7F******** *************** ***********@mic rosoft.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***@discussi ons.microsoft.c omwrote in message
news:0E******** *************** ***********@mic rosoft.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
309
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 the changes on the screen. On the Following code you can see that the code is executed but where the window was there is the rest of the window that...
4
4493
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 callback method is not counted. Do we have an equivalent of
2
8963
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
4949
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 folders to be watched. Each folder is assigned with a timer for watching purpose. Hence there will be 18 timers and each timer is set to elapse on every...
5
9866
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 regularly; like every 1.5 secs. or so. I only ran into one issue - the MyTimer_Elapsed event handler was not updating the screen correctly all the time,...
4
4623
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 program is like so: static void Main() {
11
9274
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, y1, x2, y2); }
29
8143
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"> //Global vars to hold connection to web pages var request;
3
3858
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 Thread)? In some of the timers I update some UI controls e.g statusbar.labels and I
0
7664
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7885
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8106
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6250
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5484
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2082
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1198
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.