CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Mouse commands

  1. #1
    Guest

    Mouse commands

    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?


  2. #2
    Join Date
    Dec 1999
    Location
    Israel
    Posts
    101

    Re: Mouse commands

    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!


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured