Board index » delphi » #$!*#&@!## Mouse Move

#$!*#&@!## Mouse Move

I've got a TImage sitting in a TScrollBox, so I get scrollbars.  I allow
the user to mousedown on the TImage, then
'drag' the image in whatever direction he/she wishes.  I do this by
saving the Mouse (x,y) at mouse down, then computing a delta x and y
which I apply to the scroll thumb position of the scroll bar.  Works
cool.

When I get to the edge of an image I need to go read another one.  In my
MouseMove code, I see if the scroll thumb position would be exceeded by
adding deltax, and if so, I load the next image over.

My problem is this.  When I am single stepping through the program, I
see that I load the correct image, but when I run realtime, it appears
to skip over images.  It seems as thought the mouse move is being
executed again.

I think what is happening is this:  When I reset a scollbar position,
the mouse coordinates are updated to some new spot on the screen, even
though I have not moved the mouse.  This causes my mousemove
calculations to think that another new image is needed.

Any advice on handling the mouse move?

--
Wayne Herbert
Manager, Computer Products
Key Maps, Inc.
1411 West Alabama
Houston, TX  77006

Vox:  713.522.7949
Fax:  713.521.3202
Email:  wherb...@rice.edu

"Why is it only drug dealers and software developers call their clients
'users'?"

 

Re:#$!*#&@!## Mouse Move


Wayne,

I also use a TImage within a scrollbox which I allow the user to drag
around. It works like the map panning you would see in MapInfo or ArcView.
But I chose not to update the scrollbar, but to simply capture the current
TImage canvas to a metafile and then copy this metafile back to the canvas
in the new position as I drag it around.

When I have it positioned, I regenerate the image to fill the scrollbox.
When I drag it around, I have 'white space' around the image as it is
dragged but the users don't care as they can still see where the map is
going.

And I realize this doesn't answer your main question, it just presents an
alternate methodology.

Regards, Ian

--
Ian Bakker
Calido Software Inc.
http://www.calido.com/

Re:#$!*#&@!## Mouse Move


Thanks, I appreciate that alternate view.  I want to stick with scroll bars
since I have the added task of adding new bitmaps on one end of the image as
the bitmap is being panned.  Before the limit of a scroll bar is reached, I
want to kick off a thread to get the next expected bitmap(s) into a buffer,
then shift the image, add the new bitmap and redisplay.  This should minimized
the jerkiness that will occur waiting for new bitmaps to load.

I think my problem has to do with the fact that if you reset the scroll bar
positions, the mouse cursor position must be updated since, even though the
mouse has not moved, the image has moved relative to the mouse.  This does not
seem to generate a call to the OnMouseMove when I single step the program but
dang, it sure seems like that is what is happening when not in debug mode.
The first time the mouse is moved, even one pixel, the change in mouse coords
is the same amount as the change in scroll bar thumb position. When I hols the
mouse down, I get an oscillating scroll thumb.

Quote
Ian Bakker wrote:
> Wayne,

> I also use a TImage within a scrollbox which I allow the user to drag
> around. It works like the map panning you would see in MapInfo or ArcView.
> But I chose not to update the scrollbar, but to simply capture the current
> TImage canvas to a metafile and then copy this metafile back to the canvas
> in the new position as I drag it around.

> When I have it positioned, I regenerate the image to fill the scrollbox.
> When I drag it around, I have 'white space' around the image as it is
> dragged but the users don't care as they can still see where the map is
> going.

> And I realize this doesn't answer your main question, it just presents an
> alternate methodology.

> Regards, Ian

> --
> Ian Bakker
> Calido Software Inc.
> http://www.calido.com/

--
Wayne Herbert
Manager, Computer Products
Key Maps, Inc.
1411 West Alabama
Houston, TX  77006

Vox:  713.522.7949
Fax:  713.521.3202
Email:  wherb...@rice.edu

"Why is it only drug dealers and software developers call their clients
'users'?"

Re:#$!*#&@!## Mouse Move


Wayne,

Quote
>I've got a TImage sitting in a TScrollBox, so I get scrollbars.  I allow
>the user to mousedown on the TImage, then....

I don't know if this is the best way of doing this, but for test purposes
why not define a global value (in this example TestBoolean) and try this.

Procedure MouseMove(...)
Begin
If TestBoolean Then Exit;
TestBoolean := True;
do your normal code...
TestBoolean := False;
Exit;

This will at least test your theory of re-entry...

Kindest regards

Matthew Augier
data product services
E-Mail : Matt...@DPS.uk.com
Web : http://www.DPS.uk.com

Other Threads