Mouse position


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Mouse position

  1. #1
    Join Date
    Apr 2005
    Location
    South Africa
    Posts
    88

    Question Mouse position

    Hi,
    How to:
    If I move the mouse pointer over a specific X and Y coordinate, I want to run a function.
    If I have a button on my form and I move the mouse pointer over the buttons (x , y) coordinates the function must run. Then if the mouse is moved away from the button a different function must run.

    Hope you understand what I'm trying to say!

    Thanks for you're help in advance!

  2. #2
    Join Date
    Feb 2004
    Location
    Colton, CA
    Posts
    550
    Take a look at:

    Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long

    API

  3. #3
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    You may also call your function from the MouseMove event of the form or control over which you're moving the mouse.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  4. #4
    Join Date
    Apr 2005
    Posts
    13
    yeah... the mousemove event's probably easier.

    Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

    if X = [your x value] and Y = [your y value] then
    call Myfunction
    else
    call MyOtherfunction
    end if

    End Sub



    However, if you only want the program to call the function while the mouse is over a particular button, you have to use the Command1.Top and Command1.Left declarations:

    if X = Command1.Left and Y = Command1.Top then
    call Myfunction
    else
    call MyOtherfunction
    end if

    However, even if you use exactly that statement the program will only call the function on that one point (Command1.Left, Command1.Top). So you'll have to do some math with the Command1.Height and Command1.Width variables.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center