I am trying to achieve hover effects in a windows forms application. I have a list of 19 or so items beside a summary box. When a user mouses over a menu item, it does several things:
1) Border is drawn around menu item and bg color set to white with a small alpha level.
2) an invisible connector line (1px tall picturebox) becomes visible connecting the menu item to the summary box.
3) The summary box has a Border drawn around it and bg color set to white with a small alpha level.
4) The summary text is changed from "" to the appropriate summary information.
Reverse this on MouseLeave.
Problem is, if you move the mouse normally, it doesn't register the mouseleave event as occurring, leaving the mouseenter state all over the place, showing incorrect summary data and just generally looking horrible. It only works properly at very slow speed. I have posted sample code below showing how I am doing this.
Is there a way to do this without the errors? Or, is there a faster method that would require the user to move the mouse much faster in order to generate the errors? Currently, the mouse must be moved at a speed far below the average user's mouse movement speed.
Thanks!
1) Border is drawn around menu item and bg color set to white with a small alpha level.
2) an invisible connector line (1px tall picturebox) becomes visible connecting the menu item to the summary box.
3) The summary box has a Border drawn around it and bg color set to white with a small alpha level.
4) The summary text is changed from "" to the appropriate summary information.
Reverse this on MouseLeave.
Problem is, if you move the mouse normally, it doesn't register the mouseleave event as occurring, leaving the mouseenter state all over the place, showing incorrect summary data and just generally looking horrible. It only works properly at very slow speed. I have posted sample code below showing how I am doing this.
Code:
'event pair
Private Sub lblManageInventory_MouseEnter(ByVal sender As Object, ByVal e As System.EventArgs) Handles lblManageInventory.MouseEnter
Menu_DHTML(True, Me.lblManageInventory, Me.lblHoverDescription, Me.pbxManageInventory)
Me.lblHoverDescription.Text = "Available functionality: " & vbCrLf & vbCrLf & "Receive Inventory." & vbCrLf _
& "Adjust Inventory." & vbCrLf _
& "View Inventory Report." & vbCrLf
End Sub
Private Sub lblManageInventory_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles lblManageInventory.MouseLeave
Menu_DHTML(False, Me.lblManageInventory, Me.lblHoverDescription, Me.pbxManageInventory)
Me.lblHoverDescription.Text = ""
End Sub
Code:
'Called by event pair
Private Sub Menu_DHTML(ByVal MouseEnter As Boolean, ByRef objMenuItem As System.Windows.Forms.Label, ByRef objHelpFrame As System.Windows.Forms.Label, ByRef objPBXLine As System.Windows.Forms.PictureBox)
If MouseEnter Then
objMenuItem.BackColor = Color.FromArgb(32, 255, 255, 255)
objHelpFrame.BackColor = Color.FromArgb(32, 255, 255, 255)
objMenuItem.BorderStyle = BorderStyle.FixedSingle
objHelpFrame.BorderStyle = BorderStyle.FixedSingle
objPBXLine.Visible = True
Else
objMenuItem.BackColor = Color.FromArgb(0, 255, 255, 255)
objHelpFrame.BackColor = Color.FromArgb(0, 255, 255, 255)
objMenuItem.BorderStyle = BorderStyle.None
objHelpFrame.BorderStyle = BorderStyle.None
objPBXLine.Visible = False
End If
End Sub
Is there a way to do this without the errors? Or, is there a faster method that would require the user to move the mouse much faster in order to generate the errors? Currently, the mouse must be moved at a speed far below the average user's mouse movement speed.
Thanks!