Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleDisplay multiple popups depending on whether Ctrl or Shift is pressed
DescriptionThis example shows how to display multiple popups depending on whether Ctrl or Shift is pressed in Visual Basic 6.
Keywordspopup menu, popup, context menu, PopupMenu, Ctrl, Shift
CategoriesControls, Software Engineering
 
Thanks to Chris Wagg.

In the MouseDown event handler, check the Shift parameter to see if Ctrl of Shift was pressed and display the appropriate popup.

 
Private Sub Form_MouseDown(Button As Integer, Shift As _
    Integer, X As Single, Y As Single)
    ' Look for right click.
    If Button = vbRightButton Then
        If ((Shift And vbCtrlMask) > 0) And _
           ((Shift And vbShiftMask) > 0) _
        Then
            ' Ctrl-Shift click.
            PopupMenu mnuCtrlShift
        ElseIf (Shift And vbCtrlMask) > 0 Then
            ' Ctrl click.
            PopupMenu mnuCtrl
        ElseIf (Shift And vbShiftMask) > 0 Then
            ' Shift click.
            PopupMenu mnuShift
        Else
            PopupMenu mnuRegular
        End If
    End If
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated