MOUSE move event lost label

User avatar
sal21
PlatinumLounger
Posts: 4169
Joined: 26 Apr 2010, 17:36

MOUSE move event lost label

Post by sal21 »

i have a label1 on a form

possible to check, with mouse move event, when the cursor is out the label1?

User avatar
HansV
Administrator
Posts: 75751
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: MOUSE move event lost label

Post by HansV »

You could use code like this:

Code: Select all

Private blnOnLabel As Boolean

Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    blnOnLabel = True
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    blnOnLabel = False
End Sub
When the mouse is over the label, the variable blnOnLabel is True, otherwise it is False.

If you have controls that are immediately adjacent to the label, you have to set blnOnLabel = False in the MouseMove event of those controls too.
Regards,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4169
Joined: 26 Apr 2010, 17:36

Re: MOUSE move event lost label

Post by sal21 »

HansV wrote:
09 Nov 2022, 11:08
You could use code like this:

Code: Select all

Private blnOnLabel As Boolean

Private Sub Label1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    blnOnLabel = True
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    blnOnLabel = False
End Sub
When the mouse is over the label, the variable blnOnLabel is True, otherwise it is False.

If you have controls that are immediately adjacent to the label, you have to set blnOnLabel = False in the MouseMove event of those controls too.
OPS...

have an array label, named LP.
in effect when the cursor is not on one of the labels of the array, i need:

Me.LPR.Caption = ""
Me.LPROVINCIA.Caption = ""

i use:

Code: Select all

Private Sub LP_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)

    PR = Me.LP.Item(Index).Tag

    For I = LBound(DBPR) To UBound(DBPR)
        If Left(DBPR(I), 2) = PR Then
            PROVINCIA = Split(DBPR(I), "-")(1)
            Exit For
        End If
    Next I

    Me.LPR.Caption = PR
    Me.LPROVINCIA.Caption = PROVINCIA
    DoEvents

End Sub

User avatar
HansV
Administrator
Posts: 75751
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: MOUSE move event lost label

Post by HansV »

Try

Code: Select all

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Me.LPR.Caption = ""
    Me.LPROVINCIA.Caption = ""
End Sub
I cannot test this myself!
Regards,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4169
Joined: 26 Apr 2010, 17:36

Re: MOUSE move event lost label

Post by sal21 »

HansV wrote:
09 Nov 2022, 12:10
Try

Code: Select all

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Me.LPR.Caption = ""
    Me.LPROVINCIA.Caption = ""
End Sub
I cannot test this myself!
actually...

in effect i have a picturebox1 and the Italy map.

Each black initial have a lp label of array, the tag of each lp, have initial of city.
You do not have the required permissions to view the files attached to this post.

User avatar
HansV
Administrator
Posts: 75751
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: MOUSE move event lost label

Post by HansV »

I'm afraid I cannot offer further help. Sorry!
Regards,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4169
Joined: 26 Apr 2010, 17:36

Re: MOUSE move event lost label

Post by sal21 »

HansV wrote:
09 Nov 2022, 13:40
I'm afraid I cannot offer further help. Sorry!
what do you think about it:

Code: Select all


Private Sub LP_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)

    PR = Me.LP.ITEM(Index).Tag

    For I = LBound(DBPR) To UBound(DBPR)
        If Left(DBPR(I), 2) = PR Then
            PROVINCIA = Split(DBPR(I), "-")(1)
            Exit For
        End If
    Next I

    Me.LPR.Caption = PR
    Me.LPROVINCIA.Caption = PROVINCIA
    DoEvents

End Sub

Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

    Me.LPR.Caption = ""
    Me.LPROVINCIA.Caption = ""
    DoEvents

End Sub


User avatar
HansV
Administrator
Posts: 75751
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: MOUSE move event lost label

Post by HansV »

I don't have VB6, so I have no idea. Does it work for you?
Regards,
Hans

User avatar
sal21
PlatinumLounger
Posts: 4169
Joined: 26 Apr 2010, 17:36

Re: MOUSE move event lost label

Post by sal21 »

HansV wrote:
09 Nov 2022, 15:54
I don't have VB6, so I have no idea. Does it work for you?
yes!

User avatar
HansV
Administrator
Posts: 75751
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: MOUSE move event lost label

Post by HansV »

That's good!
Regards,
Hans