M
Markus Minichmayr
Hi all!
I'm writing a windows application, that contains a control that shows a
bitmap. The bitmap is painted in the controls OnPaint method, using the
Graphics.DrawImage method. It is possible to drag the bitmap around inside
the control, using the mouse. While dragging the image, I call the controls'
Invalidate method every time i get a MouseMove-event. So far so good. The
problem is, that, when the image is large and I drag it around and then stop
moving the mouse, the image often still keeps moving over the control for a
few more seconds. I guess, this is caused by MouseMove events, still
contained in the applications message queue. A profiling utility showed,
that OnPaint was called exactly as often as MouseMove. I was surprised about
that, since I thought that OnPaint would be called asynchronously and only
when there is time for.
Can anybody explain this to me? How can it happen, that there are MouseMove
events in the queue for such a long time and why is OnPaint obviously called
every single time, Invalidate is called? (I don't call Update!)
Is there a possibility, to drop all MouseMove and Paint events, currently
contained in the message queue, except the last ones?
Does anyone know another solution for the problem?
If this is the wrong NG for my question, wher else should I post it?
Thanks for any comments
Markus
I'm writing a windows application, that contains a control that shows a
bitmap. The bitmap is painted in the controls OnPaint method, using the
Graphics.DrawImage method. It is possible to drag the bitmap around inside
the control, using the mouse. While dragging the image, I call the controls'
Invalidate method every time i get a MouseMove-event. So far so good. The
problem is, that, when the image is large and I drag it around and then stop
moving the mouse, the image often still keeps moving over the control for a
few more seconds. I guess, this is caused by MouseMove events, still
contained in the applications message queue. A profiling utility showed,
that OnPaint was called exactly as often as MouseMove. I was surprised about
that, since I thought that OnPaint would be called asynchronously and only
when there is time for.
Can anybody explain this to me? How can it happen, that there are MouseMove
events in the queue for such a long time and why is OnPaint obviously called
every single time, Invalidate is called? (I don't call Update!)
Is there a possibility, to drop all MouseMove and Paint events, currently
contained in the message queue, except the last ones?
Does anyone know another solution for the problem?
If this is the wrong NG for my question, wher else should I post it?
Thanks for any comments
Markus