Results 1 to 4 of 4

Thread: mouse move

  1. #1

    Thread Starter
    Fanatic Member vishalmarya's Avatar
    Join Date
    Feb 2001
    Location
    New Delhi , INDIA
    Posts
    858

    mouse move

    My form contains a label and a textbox

    What i want is , when my mouse moves over the textbox ,

    label should show a text message , and show blank when the mouse is no longer on the textbox.

    i used the mousemove event of the textbox and form , but in case another textbox is placed close to this textbox , and if i immediately takes the mouse to this second textbox , label does not get blank .


    Any solutions ?

    Thanks.

  2. #2
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
    4. Private Declare Function GetCapture Lib "user32" () As Long
    5. Private Declare Function ReleaseCapture Lib "user32" () As Long
    6.  
    7. Private Sub Text1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    8.  
    9.     With Text1
    10.         If ((X < 0) Or (X > .Width) Or (Y < 0) Or (Y > .Height)) Then  'MouseOut
    11.             Call ReleaseCapture
    12.             Label1.Caption = "Mouse Out!"
    13.         ElseIf GetCapture <> .hwnd Then 'MouseEnter
    14.             Call SetCapture(.hwnd)
    15.             Label1.Caption = "Mouse Enter!"
    16.         Else
    17.             'Mouse Move
    18.         End If
    19.     End With
    20.  
    21. End Sub
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

  3. #3
    Member haravinth's Avatar
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    61
    how do i do the same thing to image box instead of using text box???

    i tried this code with image box and itz saying error.

  4. #4
    The Devil crptcblade's Avatar
    Join Date
    Aug 2000
    Location
    Quetzalshacatenango
    Posts
    9,091
    For future reference, you might want to start off with what the error is.

    However, in this case, I know what it is. Imageboxes do not have a hWnd property, which this method relies on to work. There have been a couple ways posted before on how to get around this using controls without hWnds.
    Laugh, and the world laughs with you. Cry, and you just water down your vodka.


    Take credit, not responsibility

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