Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
XML RSS Feed
 
 
 
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
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-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated