Hello!
Here's another one of my eVB extension modules. With this one, you can display any of the menus added to a CommandBar as a popup menu, similar to the
PopupMenu function in the desktop version of VB6.
A complete application could look like this:
Private Const MENU_INDEX As Long = 0 'The first menu in the CommandBar.
Private Const MENUITEM_INDEX As Long = 0 'The 'File' menu item.
Private Sub Form_Load()
Dim objMenuBar As CommandBarMenuBar
Set objMenuBar = CommandBar.Controls.Add(cbrMenuBar, "Menu" )
Dim objMenuItem As CommandbarLib.Item, objSubMenuItem As CommandbarLib.Item
'File Menu
Set objMenuItem = objMenuBar.Items.Add(, "File", "&File" )
objMenuItem.SubItems.Add , "Exit", "&Exit"
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
If Shift = 4 Then 'Detect if Alt is pressed.
PopupMenu_Show Me, MENU_INDEX, MENUITEM_INDEX, 0 'Displays the 'File' menu.
End If
End Sub
The GitHub repository has more information and usage instructions.
The popup menus can be triggered either by Alt-tapping the form or right clicking with an attached mouse. The MouseDown event in eVB does not seem to detect right-clicks at all so I wrote my own function to handle this, it is included with the test project in
MouseHelper.bas. If you only want to support touch-based H/PC devices you can omit this module. I only have my HP Jornada 680 and the emulator to test so I would greatly appreciate it if someone could try out the example application on a mouse-equipped Windows CE device.
I have attached a compiled version of the example application along with some screenshots.
Links:
GitHub RepoEdited by WinCEDev 2023-07-13 2:38 PM
(CAPT0000.png)
(CAPT0001.png)Attachments
----------------
eVB Popup Menu Example.vb (12KB - 1 downloads)
CAPT0000.png (3KB - 0 downloads)
CAPT0001.png (3KB - 0 downloads)