When the user clicks the right button on a file in your namespace, or drags a file with the right button into your namespace, Opus calls functions in your plugin to build a context menu for display to the user. The two functions responsible for this are VFS_GetContextMenu and VFS_GetDropMenu and they are very similar.
BOOL VFS_GetContextMenu( HANDLE hVFSData, LPVFSFUNCDATA lpFuncData,
LPTSTR lpszFiles,
LPVFSCONTEXTMENUDATA lpMenuData )
hVFSData is your namespace instance handle, and lpFuncData is currently unused. lpszFiles is a double null-terminated list of files, providing the full pathnames of the files the user right-clicked on. lpMenuData points to a VFSCONTEXTMENUDATA structure.
By comparison, the VFS_GetDropMenu function is almost identical:
BOOL VFS_GetDropMenu( HANDLE hVFSData, LPVFSFUNCDATA lpFuncData,
LPTSTR lpszFiles,
LPVFSCONTEXTMENUDATA lpMenuData,
DWORD dwEffects )
The only addition to this function definition is the dwEffects parameter which is a mask of the OLE drag-and-drop "effects" currently in use when the drop occurred (that is, DROPEFFECT_COPY indicates the control key was held down, DROPEFFECT_MOVE indicates the shift key and DROPEFFECT_LINK indicates the alt key. DROPEFFECT_NONE indicates no qualifier keys were held down when the drop occurred.)
The VFSCONTEXTMENUDATA structure is defined as follows:
The lpCustomItems member points to an array of VFSCONTEXTMENUITEM structures that you supply. This structure is defined as follows:
| VFSCMF_CHECKED | displays a checkmark next to the menu item |
| VFSCMF_RADIOCHECK | the checkmark is displayed as a radio button |
| VFSCMF_DISABLED | the item is disabled and cannot be selected |
| VFSCMF_SEPARATOR | the item is a separator bar |
| VFSCMF_BEGINSUBMENU | the item begins a submenu |
| VFSCMF_ENDSUBMENU | the item is the last in a submenu |
Note that if you set the fFreeCustomItems flag to TRUE to have Opus free the menu item array, only the memory pointed to by lpCustomItems is freed - the individual strings in each VFSCONTEXTMENUITEM structure are not. Therefore the strings must either be statically defined in your plugin, or must be part of the memory chunk that you allocated for lpCustomItems. Otherwise you may leak memory when the user displays your context menu.
The command string pointed to by lpszCommand defines the command that is executed when the user chooses that menu item. This can be any raw Opus command (for example, "Go OPENINDUAL") or it can be a user-defined command verb. To specify your own commands, select a verb keyword and prefix it with a $ character. This verb (minus the leading $ character) will be passed to your VFS_ContextVerb function when the user selects this command from the context menu. For example, a context menu item whose lpszCommand string was set to "$viewfile" would trigger a call to VFS_ContextVerb with the lpszVerb parameter set the "viewfile".
If you do not want to add your own context menu items and simply want Opus to display default context menus, you do not need to provide the context menu functions.