BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

When mouse move fast

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics
View previous topic :: View next topic  
Author Message
Shahram Shafieha
Guest





PostPosted: Mon Jun 07, 2004 1:16 pm    Post subject: When mouse move fast Reply with 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
Kursat
Guest





PostPosted: Wed Jun 09, 2004 10:42 am    Post subject: Re: When mouse move fast Reply with quote



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





PostPosted: Wed Jun 09, 2004 12:53 pm    Post subject: Re: When mouse move fast Reply with quote



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





PostPosted: Thu Jun 10, 2004 6:38 pm    Post subject: Re: When mouse move fast Reply with 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.

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





PostPosted: Sat Jun 12, 2004 1:03 pm    Post subject: Re: When mouse move fast Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Graphics All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.