Sample C++ code to disable most menu commands using a MRR file

I teach this technique in the ProjectWise SDK training course, but enough users have asked me for an "easy" way to disable one or more menu commands so that users cannot use them.

I created a sample where you can disable most of the menu commands that you see in ProjectWise Explorer.  Note that menus added by other "Custom Modules" that use the PW SDK API functions for menus, would have to be modified using those same API functions.

For a list of available menu items, take a look at the ProjectWise SDK help and you will find them under "Menu Structures -. <menu type> IDs":

Note that the "name" of the menu id isn't always obvious.  For example, in my sample code, I am disabling the Document Menu Item "Send To -> Mail Recipient...", which as a menu id of IDMD_SEND_MAIL.

Also note that the menu command if it is disabled with a state function, is never actually called because the user cannot select it from the menu.  HOWEVER, some menu commands can be executed by some other method.  For example the Document Delete menu item can be executed by pressing the "Del" key on your keyboard.  This means that to disable the actual menu command behind the menu item, you need to replace that action with "nothing".  So, that is the reason for defining a function for the "Function Name:" box in the .MRR file.

Also make note that the function that you call for each "Command Type" has a different function prototype, so take a look at the documentation for MRR files:

I created my Custom Module as a MFC DLL so you will need to make sure that those DLLs are on your target machines, or you can use my source code with a "Win32" DLL project.

I also put the Exercises for the part of the PW SDK training that includes how to disable a menu command as well as other things you can do with a MRR file up on my GitHub site.

You can get the sample project here: Sample-DisableMenuCmds

Hope this helps a few folks!

Parents Reply Children
No Data