🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.visual.basic
Article #13

Re: Tracking Mouse Position Over An Object?

#13
From: Greg Siemon
Date: Sun, 09 Jan 2000 00:00
68 lines
3806 bytes
This could help.  It will track the mouse move regardless of the scaling
system of the control.  Also provides for optional clipped area if control
is inside a smaller control.

For your problem at MouseMove you will get MouseOver = True even if mouse is
over another control

Try:
++++++++++++++++++++++++++++++++++++++++++++++++
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single,
Y As Single)
If MouseOver(Me, X, Y) Then Beep
End Sub
+++++++++++++++++++++++++++++++++++++++++++++++++
Public Declare Function ReleaseCapture Lib "user32" () As Long
Public Declare Function SetCapture Lib "user32" (ByVal hwnd As Long) As Long
Public Function MouseOver(Control As Object, X As Single, Y As Single, _
        Optional NewScaleLeft As Variant, Optional NewScaleWidth As Variant,
_
        Optional NewScaleTop As Variant, Optional NewScaleHeight As Variant)
As Boolean

Static MouseOverSW As Boolean, Ret As Long
Dim ControlScaleLeft As Single, ControlScaleWidth As Single
Dim ControlScaleTop As Single, ControlScaleHeight As Single

ControlScaleLeft = Control.ScaleLeft
ControlScaleWidth = Control.ScaleWidth
ControlScaleTop = Control.ScaleTop
ControlScaleHeight = Control.ScaleHeight

If Not IsMissing(NewScaleLeft) Then ControlScaleLeft = NewScaleLeft
If Not IsMissing(NewScaleWidth) Then ControlScaleWidth = NewScaleWidth
If Not IsMissing(NewScaleTop) Then ControlScaleTop = NewScaleTop
If Not IsMissing(NewScaleHeight) Then ControlScaleHeight = NewScaleHeight

If TypeOf Control Is PictureBox Or _
    TypeOf Control Is Form Or _
    TypeOf Control Is UserDocument Or _
    TypeOf Control Is MDIForm Then
    If Sgn(ControlScaleWidth) = Sgn(ControlScaleLeft - X) Or _
        Sgn(ControlScaleWidth) <> Sgn(ControlScaleWidth + ControlScaleLeft -
X) Or _
        Sgn(ControlScaleHeight) = Sgn(ControlScaleTop - Y) Or _
        Sgn(ControlScaleHeight) <> Sgn(ControlScaleHeight +
ControlScaleTop - Y) Then
        MouseOverSW = False
        Ret = ReleaseCapture()
        Else
        Ret = SetCapture(Control.hwnd)
        MouseOverSW = True
        End If
    End If
MouseOver = MouseOverSW
End Function

--
Greg Siemon
gsiemon@home.net
LWP <news@lwp.cc> wrote in message
news:SAKd4.5009$%K1.239927@tw12.nn.bcandid.com...
> i know how to track the mouse position over a form but when the mouse goes
> over a label or any other component, the mouse position doesn't update
> untill you run the mouse to the other side.
>
> Can you add Mousemove to the other components?
>
>
Technical Details
Message-ID: <u0rO7prW$GA.266@cppssbbsa05>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <SAKd4.5009$%K1.239927@tw12.nn.bcandid.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10f676,ebb1ac14b632be9f
X-Google-Attributes: gid10f676,public
X-Google-Thread: faef3,ebb1ac14b632be9f
X-Google-Attributes: gidfaef3,public
X-Google-Thread: fb992,ebb1ac14b632be9f
X-Google-Attributes: gidfb992,public
X-Google-Thread: 10b213,ebb1ac14b632be9f
X-Google-Attributes: gid10b213,public
X-Google-Thread: 10a872,ebb1ac14b632be9f
X-Google-Attributes: gid10a872,public
X-Google-Thread: ffb5a,ebb1ac14b632be9f
X-Google-Attributes: gidffb5a,public
X-Google-Thread: 11493c,ebb1ac14b632be9f
X-Google-Attributes: gid11493c,public
X-Google-Thread: 108062,ebb1ac14b632be9f
X-Google-Attributes: gid108062,public
From: "Greg Siemon" <gsiemon@home.com>
Subject: Re: Tracking Mouse Position Over An Object?
Date: 2000/01/09
Message-ID: <u0rO7prW$GA.266@cppssbbsa05>
X-Deja-AN: 570379396
References: <SAKd4.5009$%K1.239927@tw12.nn.bcandid.com>
Newsgroups: comp.lang.visual.basic,comp.lang.visual.basic.misc,cz.comp.lang.basic.visual,microsoft.public.scripting.vbscript,microsoft.public.vb.addins,microsoft.public.vb.controls,microsoft.public.vb.enterprise,microsoft.public.vb.general.discussion,microsof
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300