Results 1 to 3 of 3

Thread: [RESOLVED] If mouse is outside a label Then...

  1. #1

    Thread Starter
    Addicted Member cc2^^'s Avatar
    Join Date
    Apr 2008
    Location
    Right behind you.
    Posts
    165

    Resolved [RESOLVED] If mouse is outside a label Then...

    As the title says, is it possible to excecute a line of code when your mouse is over a label, then when it's moved outside the label? I succeded to run a line of code by having your mouse over the label.

    Code:
    Private Sub Label6_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Label6.Caption = "-Exit-" 'the label was first "Exit". It's like making a label to a button.
    End Sub
    If you know how to run a code when the mouse is outside the label, please reply back. Thanks!
    I think I am, therefore, I am. I think.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: If mouse is outside a label Then...

    Because Label's do not have an .hWnd property, doing what you ask is a bit hit or miss.

    Try using the Form_Move event.

  3. #3
    PowerPoster
    Join Date
    Oct 2008
    Location
    Midwest Region, United States
    Posts
    3,574

    Re: If mouse is outside a label Then...

    I would try to identify the boundaries of the label, then use something like this to figure out where the cursor is:

    Code:
    Dim cur_point As POINTAPI
    
    Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    
    Private Type POINTAPI
        X As Long
        Y As Long
    End Type
    Put the above code in your General Declarations.

    Code:
    GetCursorPos cur_point
    Put the above in a timer event and check the current coordinates against the boundaries of the label.

    Let me know if that makes sense!

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