Click to See Complete Forum and Search --> : Mouse commands


December 20th, 1999, 04:41 PM
How do I make it so when the mouse is moved by the user, a picture box moves along with it? Say, if the mouse moves up, so does the picture, and if it moves down, so does the picture, etc... The same with left and right. Then how can I make it so if the mouse is moved beyond a certain point, or line, in the form the picture stops at the line, and if the left mouse button is clicked, another picture is shown?

Ruth Glushkin
December 21st, 1999, 01:14 AM
First of all, you should write the following subroutine:

Private Sub Form1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Picture1.Move X, Y ' if you want to put the top left edge of the picture exactly where your mouse is or X +/- value, Y +/- value if you want to put the picture near the mouse

Don't forget to set before Picture1.AutoRedraw = True

In the same subroutine you can also compare X and Y of the mouse with X and Y of Line, etc., and
to move your picture exactly on your Line, etc.

According to value of Button you can also check if you pressed on Mouse Button and use it correspondingly.

Good Luck!