Win32 API Menu Demo 30 Aug, 2002
Background
R5 introduced nice cascading action bar buttons. But did you know you can have cascading menu items everywhere courtesy of the Win32 API?
The application
The attached database, in zip format, is a simple demonstration of this functionality. A combination of Win32 API calls are used to provide cascading menus in any Notes client application. See the screenshot below for more of an idea of what this application does:

Note that the example database uses action bar buttons stored in a "placeholder" page to demonstrate the menu items, but they could be triggered by all kinds of click events in the Notes client. The code has also been tinkered with in the R4.x client, so cascading action bars in R4 here we come!
Functions used
All this code makes use of a number of Win32 functions, and these are…
Then, for building the menu itself…
- GetCursorPos
- CreatePopupMenu
- AppendMenu
- TrackPopupMenu
Clean up…
- DestroyMenu
- GetMessage
Structuring your menus
The code is the simple bit; by far the most complex issue is structuring your cascading menus. Which option should be greyed-out and when? How many levels could / should a menu go to? All such questions need to be addressed. The database code contains some sample guidelines with regards menu construction.
The example database is coded so that via a messagebox, it prompts the user with the name of the menu item selected — it does nothing more than that. Effectively this code provide you with a model for generating menus and performing an — albeit crude — system of event handling.
The rest is up to you!
Question
I cannot get MF_DISABLED or MF_GRAYED to work with Windows 2000. MF_CHECKED works.
Now here's the kicker. I copied the code into VB and it works, including MF_DISABLED and MF_GRAYED.
Any ideas why?
John Burgman#
As to why… hmmm. In the past, when I've had Win32 code that doesn't work in Lotusscript (or even stuff that doesn't work between versions of Notes — see my GetOpenFilename article), it's usually down to dodgy structures or buffers. That may be one place to look. To be honest, I hadn't even tried this code directly in VB, so had no idea that those additional options worked there!Ben Poole#
CreateObject("VB2Notes.Application")
This allows me to do various things like running ADO queries, using Excel, etc. working with the VB app space which directly in Notes caused memory leaks, BRBs, etc. Now I can safely do all that with little or no problems. And all this while still using Notes version 4.67a.
Move to version 6? I'm working on it but for the moment I have pretty much everything needed to keep my company's business moving along just fine.
John Burgman#
and i have not the lss file!punk#
I like the Win32 API popup menu but…
Disabled and Greyed do not seem to work. I have copied and pasted the code into Visual Basic and these 2 options work so I'm back guessing that somehow, since the menu must be related to the active window, the Notes window is not allowing the popup menu to correctly use those 2 options.
FYI: I am using Notes version 4.6.7a
Any idea why?John Burgman#