x
This website is using cookies. We use cookies to ensure that we give you the best experience on our website. More info. That's Fine
HPC:Factor Logo 
 
Latest Forum Activity

Display popup menus from your eVB application

WinCEDev Page Icon Posted 2023-07-13 1:45 PM
#
Avatar image of WinCEDev
Factorite (Senior)

Posts:
76
Location:
Europe
Status:
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 Repo

Edited by WinCEDev 2023-07-13 2:38 PM




(CAPT0000.png)



(CAPT0001.png)



Attachments
----------------
Attachments eVB Popup Menu Example.vb (12KB - 1 downloads)
Attachments CAPT0000.png (3KB - 0 downloads)
Attachments CAPT0001.png (3KB - 0 downloads)
 Top of the page
torch Page Icon Posted 2023-07-15 8:30 AM
#
Avatar image of torch
Subscribers
H/PC Guru

Posts:
5,738
Location:
United StatesĀ 
Status:
Thanks for posting this. Always love your guides! Keep up the good work.
 Top of the page
WinCEDev Page Icon Posted 2023-08-18 12:01 AM
#
Avatar image of WinCEDev
Factorite (Senior)

Posts:
76
Location:
Europe
Status:
Just a quick side-note to save anyone else the trouble. Sadly, the popup menus currently do not work correctly if you want to trigger them from my notification icon module.

The reason for that is in order to receive the messages from Shell_NotifyIcon, we have to (ab)use WM_MOUSEDOWN for this, since these event handlers in eVB are the only ones with the right amount of arguments.

However, when this 'fake' WM_MOUSEDOWN is sent, it also incorrectly triggers an update of the value returned by GetMessagePos, which is used to position the popup menu. Therefore the popup menu will not appear at the expected location near the notification icon.

I'll post an update if I can find a solution, alternatively you could theoretically use something like VBCEMessage to use Shell_NotifyIcon with your own window message. That way, it will not interfere with GetMessagePos.

torch - 2023-07-15 9:30 AM


Thanks for posting this. Always love your guides! Keep up the good work.


Thanks, I'm glad you enjoy them.

Edited by WinCEDev 2023-08-18 12:09 AM
 Top of the page
Jump to forum:
Seconds to generate: 0.218 - Cached queries : 60 - Executed queries : 10