Advertisement
6_2008-2009 Custom Controls/ Forms/ Menus #202786

Simple API Popup Menu Class (for context menus on the fly)

OK... not looking to blow away the world with this one, but felt lead to make the post after reading this article. http://www.planet-source-code.com/vb/scripts/showcode.asp?txtCodeId=26999&lngWId=1 At work, I have an app that is an mdi based program... and while the sub forms don't need a menu bar of their own, they do need popup context menus. Since adding even an invisible menu to a mdichild form will cause it to over write the parent mdi's menu bar, I needed a way to create menus for the child forms on the fly. This simple class demonstrates using the API calls to create a popup menu, display it, and return the item that was clicked (if any). It is simple and self-contained, but this will at least get you started on your way to wrapping the API menu functions in VB classes. I can already see I will be expanding this class, since getting this far was actually quite easy. The ultimate goal would be to "InsertMenuItem"s not just in a popup, but in the menu bar of the parent mdi form as well. I'll repost the class when I've taken it that far. (just updated to include .ItemEnabled property for the popup menu)

AI

AI Summary: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Source Code
original-source
Upload
Original Comments (3)
Recovered from Wayback Machine