Hi
I have revisited this and re-written the code.
I use the menu item hover event, not the Mouse Enter event (I can't see that event being useful for this purpose.)
This is a stand alone example, and there are two Form2 (Form1 and Form2), with only Form1 having a ConextMenuStrip1 added in the Designer.
This is as close as I can come up with to give the desired effects. The Font and colours are hard coded, but they too could be made dynamic if needed.
The biggest issue I came across was keeping the menu open and then to close it at a suitable point.
Anyway, if you want to check it out, use a new test project.
This early test forum is incapable of letting user delete stull - so just ignore the surplus code after the End Class of Form2 code.
'========= FORM 1 CODE ===========
' Form1 with a
' ContextMenuStrip1 populated
' with items
' {"One", "Two", "Three"}
Option Strict On
Option Explicit On
Public Class Form1
Dim f2 As Form2
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles Me.Load
TopMost = True
End Sub
Private Sub Form1_MouseEnter(sender As Object, e As EventArgs) Handles MyBase.MouseEnter
If ContextMenuStrip1.Visible Then
If Not f2 Is Nothing Then f2.Dispose()
ContextMenuStrip1.Close()
End If
End Sub
Private Sub ToolStripMenuItem_MouseHover(sender As Object, e As EventArgs) Handles OneToolStripMenuItem.MouseHover, TwoToolStripMenuItem.MouseHover, ThreeToolStripMenuItem.MouseHover
Dim item As ToolStripItem = DirectCast(sender, ToolStripItem)
If Not f2 Is Nothing Then f2.Dispose()
f2 = New Form2
Select Case item.Text
Case "One"
f2.Txt = "Here we are! ONE"
Case "Two"
f2.Txt = "Heer we is! TWO"
Case "Three"
f2.Txt = "There are we! THREE"
End Select
f2.Show()
End Sub
Private Sub ContextMenuStrip1_Opening(sender As Object, e As System.ComponentModel.CancelEventArgs) Handles ContextMenuStrip1.Opening
If Not f2 Is Nothing Then f2.Dispose()
End Sub
Private Sub ContextMenuStrip1_Closing(sender As Object, e As ToolStripDropDownClosingEventArgs) Handles ContextMenuStrip1.Closing
If e.CloseReason =
ToolStripDropDownCloseReason.AppFocusChange Then e.Cancel = True
End Sub
End Class
'========= FORM 2 CODE ===========
' Blank Form2
Option Strict On
Option Explicit On
Public Class Form2
' incoming toolip text
Property Txt As String
' timer int seconds
Dim sec As Integer = 3
Dim WithEvents lab As New Label
Dim WithEvents Timer1 As New Timer
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
With lab
.Font = New Font("Arial", 18)
.AutoEllipsis = False
.BackColor = Color.Blue
.ForeColor = Color.Yellow
.Dock = DockStyle.Fill
.Text = Txt
End With
With Timer1
.Interval = 1000
.Enabled = True
End With
TopMost = True
FormBorderStyle = FormBorderStyle.None
Size = TextRenderer.MeasureText(Txt, lab.Font)
Location = MousePosition
Controls.Add(lab)
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Static c As Integer = 0
c += 1
If c > sec Then
Dispose()
End If
End Sub
End Class
' =========== IGNORE ALL BELOW THIS LINE =============
Option Explicit On
Public Class Form2
' incoming toolip text
Property Txt As String
' timer int seconds
Dim sec As Integer = 3
Dim WithEvents lab As New Label
Dim WithEvents Timer1 As New Timer
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
With lab
.Font = New Font("Arial", 18)
.AutoEllipsis = False
.BackColor = Color.Blue
.ForeColor = Color.Yellow
.Dock = DockStyle.Fill
.Text = Txt
End With
With Timer1
.Interval = 1000
.Enabled = True
End With
TopMost = True
FormBorderStyle = FormBorderStyle.None
Size = TextRenderer.MeasureText(Txt, lab.Font)
Location = MousePosition
Controls.Add(lab)
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Static c As Integer = 0
c += 1
If c > sec Then
Dispose()
End If
End Sub
End Class
' Blank Form2
Option Strict On
Option Explicit On
Public Class Form2
' incoming toolip text
Property Txt As String
' timer int seconds
Dim sec As Integer = 3
Dim WithEvents lab As New Label
Dim WithEvents Timer1 As New Timer
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
With lab
.Font = New Font("Arial", 18)
.AutoEllipsis = False
.BackColor = Color.Blue
.ForeColor = Color.Yellow
.Dock = DockStyle.Fill
.Text = Txt
End With
With Timer1
.Interval = 1000
.Enabled = True
End With
TopMost = True
FormBorderStyle = FormBorderStyle.None
Size = TextRenderer.MeasureText(Txt, lab.Font)
Location = MousePosition
Controls.Add(lab)
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Static c As Integer = 0
c += 1
If c > sec Then
Dispose()
End If
End Sub
End Class
' Blank Form2
Option Strict On
Option Explicit On
Public Class Form2
' incoming toolip text
Property Txt As String
' timer int seconds
Dim sec As Integer = 3
Dim WithEvents lab As New Label
Dim WithEvents Timer1 As New Timer
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
With lab
.Font = New Font("Arial", 18)
.AutoEllipsis = False
.BackColor = Color.Blue
.ForeColor = Color.Yellow
.Dock = DockStyle.Fill
.Text = Txt
End With
With Timer1
.Interval = 1000
.Enabled = True
End With
TopMost = True
FormBorderStyle = FormBorderStyle.None
Size = TextRenderer.MeasureText(Txt, lab.Font)
Location = MousePosition
Controls.Add(lab)
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Static c As Integer = 0
c += 1
If c > sec Then
Dispose()
End If
End Sub
End Class
' Blank Form2
Option Strict On
Option Explicit On
Public Class Form2
' incoming toolip text
Property Txt As String
' timer int seconds
Dim sec As Integer = 3
Dim WithEvents lab As New Label
Dim WithEvents Timer1 As New Timer
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
With lab
.Font = New Font("Arial", 18)
.AutoEllipsis = False
.BackColor = Color.Blue
.ForeColor = Color.Yellow
.Dock = DockStyle.Fill
.Text = Txt
End With
With Timer1
.Interval = 1000
.Enabled = True
End With
TopMost = True
FormBorderStyle = FormBorderStyle.None
Size = TextRenderer.MeasureText(Txt, lab.Font)
Location = MousePosition
Controls.Add(lab)
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Static c As Integer = 0
c += 1
If c > sec Then
Dispose()
End If
End Sub
End Class
' Blank Form2
Option Strict On
Option Explicit On
Public Class Form2
' incoming toolip text
Property Txt As String
' timer int seconds
Dim sec As Integer = 3
Dim WithEvents lab As New Label
Dim WithEvents Timer1 As New Timer
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
With lab
.Font = New Font("Arial", 18)
.AutoEllipsis = False
.BackColor = Color.Blue
.ForeColor = Color.Yellow
.Dock = DockStyle.Fill
.Text = Txt
End With
With Timer1
.Interval = 1000
.Enabled = True
End With
TopMost = True
FormBorderStyle = FormBorderStyle.None
Size = TextRenderer.MeasureText(Txt, lab.Font)
Location = MousePosition
Controls.Add(lab)
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Static c As Integer = 0
c += 1
If c > sec Then
Dispose()
End If
End Sub
End Class
' Blank Form2
Option Strict On
Option Explicit On
Public Class Form2
' incoming toolip text
Property Txt As String
' timer int seconds
Dim sec As Integer = 3
Dim WithEvents lab As New Label
Dim WithEvents Timer1 As New Timer
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
With lab
.Font = New Font("Arial", 18)
.AutoEllipsis = False
.BackColor = Color.Blue
.ForeColor = Color.Yellow
.Dock = DockStyle.Fill
.Text = Txt
End With
With Timer1
.Interval = 1000
.Enabled = True
End With
TopMost = True
FormBorderStyle = FormBorderStyle.None
Size = TextRenderer.MeasureText(Txt, lab.Font)
Location = MousePosition
Controls.Add(lab)
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
Static c As Integer = 0
c += 1
If c > sec Then
Dispose()
End If
End Sub
End Class