 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Shahram Shafieha Guest
|
Posted: Mon Jun 07, 2004 1:16 pm Post subject: When mouse move fast |
|
|
Hi all,
1. I draw an image by LEADTools function on a form.
2. In MouseMove event, redraw image and, draw a rectangle around the mouse
pointer. So the old rectangle will be cleared. Position of the new rectanlge
depends on the position of the mouse.
3. By ClipRect API, define an area that mouse can not go out of this area.
This area fits the image.
4. When I move mouse slowly, always mouse will be inside of the rectangle,
and everything is ok. But if I move mouse fast, the pointer will go out of
the rectangle. Why?
Can anybody help me?
|
|
| Back to top |
|
 |
Kursat Guest
|
Posted: Wed Jun 09, 2004 10:42 am Post subject: Re: When mouse move fast |
|
|
How do you draw the rectangle? How do you calculate coordinates? Can you
post rectangle-drawing part of your code?
"Shahram Shafieha" <shshafieha (AT) yahoo (DOT) com> wrote
| Quote: | Hi all,
1. I draw an image by LEADTools function on a form.
2. In MouseMove event, redraw image and, draw a rectangle around the mouse
pointer. So the old rectangle will be cleared. Position of the new
rectanlge
depends on the position of the mouse.
3. By ClipRect API, define an area that mouse can not go out of this area.
This area fits the image.
4. When I move mouse slowly, always mouse will be inside of the rectangle,
and everything is ok. But if I move mouse fast, the pointer will go out of
the rectangle. Why?
Can anybody help me?
|
|
|
| Back to top |
|
 |
Shahram Shafieha Guest
|
Posted: Wed Jun 09, 2004 12:53 pm Post subject: Re: When mouse move fast |
|
|
How do you draw the rectangle?
I draw rectangle by Rectangle API function as
Rectangle(Canvas.Handle, redRect.Left, redRect.Top, redRect.Right,
redRect.Bottom);
Canvas.Handle is the canvas of the form, and redRect is a TRect that
containt coordinates of the form.
How do you calculate coordinates?
On the FormShow I wrote:
redRect.Left := Round(a * MainImageRect.Left + rcDst.Left);
redRect.Top := Round(a * MainImageRect.Top + rcDst.Top);
redRect.Right := Round(a * MainImageRect.Right + rcDst.Left);
redRect.Bottom := Round(a * MainImageRect.Bottom + rcDst.Top);
a is a coefficient for changing coordinates, its formula is something like
this :
a := ClientWidth / (Bitmap1.Width * ZoomLevel);
Can you post rectangle-drawing part of your code?
Actually I send a part of it.
| Quote: | Hi all,
1. I draw an image by LEADTools function on a form.
2. In MouseMove event, redraw image and, draw a rectangle around the
mouse
pointer. So the old rectangle will be cleared. Position of the new
rectanlge
depends on the position of the mouse.
3. By ClipRect API, define an area that mouse can not go out of this
area.
This area fits the image.
4. When I move mouse slowly, always mouse will be inside of the
rectangle,
and everything is ok. But if I move mouse fast, the pointer will go out
of
the rectangle. Why?
Can anybody help me?
|
|
|
| Back to top |
|
 |
Dale Peyser Guest
|
Posted: Thu Jun 10, 2004 6:38 pm Post subject: Re: When mouse move fast |
|
|
I don't know what the "ClipRect" you refer to is. The only symbol in the Delphi runtime I can find with that name is the ClipRect on a Canvas which corresponds to the GDI Region that needs repainting. It wouldn't prevent the mouse from doing anything.
But anyhow, when you have SetCapture on a window, it only changes the routing of Mouse Messages within that window's thread. If there was code somewhere that looked for the mousepointer to be outside of a particular rectangle, then forced it back in it would work if the mouse moved slowly but if it moved fast, it could get outside all the thread's window's rectangles before that code could trigger. Then it wouldn't know that the mouse was gone and sending its messages somewhere else (i.e. to the desktop or some other thread)
I don't think there is any way to control the mousepointer at the OS level apart from writing your own mouse driver.
You might want to reconsider your design and change it so you don't have to limit mouse movement.
|
|
| Back to top |
|
 |
Shahram Shafieha Guest
|
Posted: Sat Jun 12, 2004 1:03 pm Post subject: Re: When mouse move fast |
|
|
I think about your suggestion, Thankyou
"Dale Peyser" <dalep (AT) pizer (DOT) removeme.com> wrote
| Quote: |
I don't know what the "ClipRect" you refer to is. The only symbol in the
Delphi runtime I can find with that name is the ClipRect on a Canvas which |
corresponds to the GDI Region that needs repainting. It wouldn't prevent the
mouse from doing anything.
| Quote: |
But anyhow, when you have SetCapture on a window, it only changes the
routing of Mouse Messages within that window's thread. If there was code |
somewhere that looked for the mousepointer to be outside of a particular
rectangle, then forced it back in it would work if the mouse moved slowly
but if it moved fast, it could get outside all the thread's window's
rectangles before that code could trigger. Then it wouldn't know that the
mouse was gone and sending its messages somewhere else (i.e. to the desktop
or some other thread)
| Quote: |
I don't think there is any way to control the mousepointer at the OS level
apart from writing your own mouse driver.
You might want to reconsider your design and change it so you don't have
to limit mouse movement. |
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|