Hi guys,
I came across an issue I had not expected when I was writing up my custom panel control. Apparently when the mouse enters a panels children it triggers a mouse leave event on the panel. This means my code does not work. I can update the custom children because the panels children need not only be custom controls. I'm kind of stumped. I though about looking to see if the mouse is in the panels border but im unsure of how to do this and imagine that the mouse would be considered out of bounds when it enters the children. Any suggestions?
VB Code:
Public Class RollOverPanel Inherits System.Windows.Forms.Panel ''' <summary> ''' Loops through each RollOver control and calls the triggeroff() method of said ''' controls. TriggerOn() changes the controls base color to its "hot" color. ''' </summary> ''' <remarks>Currently only the RollOverLabel control is tested</remarks> Private Sub ActivateHotControls() For Each Control In Me.Controls If TypeOf Control Is RollOverLabel Then Dim CurrentLabel As RollOverLabel CurrentLabel = CType(Control, RollOverLabel) CurrentLabel.TriggerOn() End If Next End Sub ''' <summary> ''' Loops through each RollOver Control and calls the triggeroff() method of said ''' controls. TriggerOff() reverts from the controls "hot" color to its base color. ''' </summary> ''' <remarks>Currently only the RollOverLabel control is tested</remarks> Private Sub DeactivateHotControls() For Each Control In Me.Controls If TypeOf Control Is RollOverLabel Then Dim CurrentLabel As RollOverLabel = CType(Control, RollOverLabel) CurrentLabel.TriggerOff() End If Next End Sub Protected Overrides Sub OnMouseEnter(ByVal e As System.EventArgs) MyBase.OnMouseEnter(e) ActivateHotControls() End Sub Protected Overrides Sub OnMouseLeave(ByVal e As System.EventArgs) MyBase.OnMouseLeave(e) 'This is the offending line. DeactivateHotControls() End Sub End Class




Reply With Quote