🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.lang.visual.basic
2 messages
2 total messages Started by LWP Sat, 08 Jan 2000 00:00
Tracking Mouse Position Over An Object?
#12
Author: LWP
Date: Sat, 08 Jan 2000 00:00
5 lines
1727 bytes
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?
Re: Tracking Mouse Position Over An Object?
#13
Author: 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?
>
>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads