Results 1 to 6 of 6

Thread: Not MouseMove

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Oct 1999
    Location
    -
    Posts
    101
    Hi! How can a control knows that the Mouse Pointer has just
    pass, sort of a LostFocus.

    I know that a MouseMove event will trigger everytime the
    mouse pointer passes through a control
    (PictureBox, Image..., Button etc...). I'd like to know
    what event will trigger if the control just lost the
    mouse pointer. Is there any... or any work around?

    Thanks for any help

    - I'm using VB 6.0 Enterprise Edition
    icq: 16228887

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    You would have to use a timer, check for the mouseposition using Getcursorpos api and check if it's in the rect of your control, using Getwindowrect for controls with hwnd or just using the left, top, width and height properties for a image
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3
    Member
    Join Date
    Aug 2000
    Posts
    60
    No, but you could use the API calls getmousepos and getwindowrect.

    If you use getwindowrect to get the rectangle of the window( that is its perimeter) you can work out if the mouse it over it or not, for this you will need a timer to monitor the cursor position and the control position, i have had to do this for one of my projects before and it did work, if you want me to mail you a demo just say.

    Hope this helps,
    Grant French
    -----------------------------------------------
    E-Mail: [email protected]
    ICQ: 33122184

  4. #4
    Member
    Join Date
    Aug 2000
    Posts
    60

    Hi Again

    Sorry, slight alteration to the previous messagem what i meant to say is if you get the cursor position you can then use get windowfrompoint to find the handle of the window under the mouse cursor, then compare this with the handle of your control.

    Sorry about that, once again if you want a demo just say
    Grant French
    -----------------------------------------------
    E-Mail: [email protected]
    ICQ: 33122184

  5. #5
    Guest
    Try this:

    Code:
    Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
    Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
    Private Type POINTAPI
            x As Long
            y As Long
    End Type
    Dim lpoint As POINTAPI
    
    Private Sub Timer1_Timer()
    
        GetCursorPos lpoint
        Retval = WindowFromPoint(lpoint.x, lpoint.y)
        'If the hWnd is the same as Command1 then...
        If Retval = Command1.hwnd Then
            Text1 = "It's on Command1"
        Else
            Text1 = "It's not on command1"
        End If
        
    End Sub

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Oct 1999
    Location
    -
    Posts
    101
    Thanks guys for your help!
    icq: 16228887

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