StatusBar & ContextMenu question

  • Thread starter Thread starter Mika Mähönen
  • Start date Start date
M

Mika Mähönen

Hello!

I have Windows Form application containing StatusBar (sb below) and also
ContextMenu for this StatusBar. StatusBar contains 2 panels, and I want to
show ContextMenu only if the MousePointer is on the sb.Panels(1) (and right
MouseButton is used) - how to do it? Maybe code below needs to be changed
but how ?

Private Sub sb_MouseUp(ByVal sender As Object, ByVal e As
System.Windows.Forms.MouseEventArgs) Handles sb.MouseUp

If e.Button = MouseButtons.Right Then

ShowContentMenu(sender)

End If

End Sub



Thanks in advance!

Mika from Finland
 
Hi Mika,

I'm just going out so I can't give you details.

MouseUp will give you the position of the Mouse. You can obtain the
position and sizes of the Panels and determine which one the mouse is over.

Sorry, I'm literally just popping in, so can't say more.

Regards,
Fergus

Oh, a-drumming and a-dancing - I will go, tra la la.... ;-)
 
* "Mika Mähönen said:
I have Windows Form application containing StatusBar (sb below) and also
ContextMenu for this StatusBar. StatusBar contains 2 panels, and I want to
show ContextMenu only if the MousePointer is on the sb.Panels(1) (and right
MouseButton is used) - how to do it? Maybe code below needs to be changed
but how ?

Try this:

\\\
Private Sub StatusBar1_PanelClick(ByVal sender As Object, ByVal e As System.Windows.Forms.StatusBarPanelClickEventArgs) Handles StatusBar1.PanelClick
If e.Button = MouseButtons.Right Then
Select Case True
Case e.StatusBarPanel Is Me.StatusBarPanel1
...
Case e.StatusBarPanel Is Me.StatusBarPanel2
...
End Select
End If
End Sub
///
 
Back
Top