The main downside to my homegrown approach is that it won't work on modal forms. However, I try to not do that, so this serves my needs well.
The main reason I did this is that I wanted popup menus with tooltips, which I accomplished.
Screenshot:
![Name: PopupWithTooltip.png
Views: 47
Size: 7.8 KB]()
Everything you need to use it is in the code in Form1. The sample project is attached, but here's the Form1 code:
You just add all your popup menu items beforehand, and then call the popup when you need it. As an FYI, you should add all your popup items beforehand (maybe in a Sub Main) and then they're there for the life of the project. However, if you put them into a Form_Load of a form that's repeatedly loaded, that's ok too, as duplicates are checked and disallowed.
Be sure to add the PopupClicked to your calling form (with the arguments shown) so you can get the info about the popup item clicked.
There are just two procedures you use in the mod_Gen_PopupSupport module (AddPopupItem & ShowPopupMenu) and that's it. The rest is just support.
Also, there is a bit of subclassing, but it's only done when the popup menu is showing. And, since it won't work on modal forms, it should be quite safe for the VB6 IDE, even if you click the Stop button. (The only place it might "get" you is if you're tracing through the popup menu code and click the IDE's Stop button while you're doing that. Tracing through your own code is fine though.)
Update001 (Jan 22, 2022): Fixed error when you right-click around extremely fast (less than 1/100th second between clicks).
The main reason I did this is that I wanted popup menus with tooltips, which I accomplished.
Screenshot:
Everything you need to use it is in the code in Form1. The sample project is attached, but here's the Form1 code:
Code:
Option Explicit
Private Sub Form_Load()
AddPopupItem "TestMenu", "Popup Item 1", "This is a tooltip for the popup item #1"
AddPopupItem "TestMenu", "Popup Item 2", "This is a tooltip for the popup item #2"
AddPopupItem "TestMenu", "-"
AddPopupItem "TestMenu", "Popup Item 3", "This is a tooltip for the popup item #3"
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then ShowPopupMenu Me, "TestMenu"
End Sub
Public Sub PopupClicked(sPopupMenu As String, sPopupItem As String)
Debug.Print "Clicked: "; sPopupMenu; " "; sPopupItem
End Sub
Be sure to add the PopupClicked to your calling form (with the arguments shown) so you can get the info about the popup item clicked.
There are just two procedures you use in the mod_Gen_PopupSupport module (AddPopupItem & ShowPopupMenu) and that's it. The rest is just support.
Also, there is a bit of subclassing, but it's only done when the popup menu is showing. And, since it won't work on modal forms, it should be quite safe for the VB6 IDE, even if you click the Stop button. (The only place it might "get" you is if you're tracing through the popup menu code and click the IDE's Stop button while you're doing that. Tracing through your own code is fine though.)
Update001 (Jan 22, 2022): Fixed error when you right-click around extremely fast (less than 1/100th second between clicks).