|
//
// (C) Copyright by Victor Derks <vba64@xs4all.nl>
//
// See README.TXT for the details of the software licence.
//
#include "stdafx.h"
#include "../include/contextmenuimpl.h"
#include "../include/smallbitmaphandler.h"
#include "../include/util.h"
#include "contextmenuclsid.h"
#include "shellfolderclsid.h"
#include "editwithnotepadcommand.h"
#include "aboutmsfcommand.h"
#include "resource.h"
class ATL_NO_VTABLE CContextMenu :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CContextMenu, &__uuidof(CContextMenu)>,
public IContextMenuImpl<CContextMenu>
{
public:
static HRESULT WINAPI UpdateRegistry(BOOL bRegister) throw()
{
return IContextMenuImpl<CContextMenu>::UpdateRegistry(IDR_CONTEXTMENU,
bRegister, L"Sample ShellExtension ContextMenu", __uuidof(CShellFolder), wszVVVExtension);
}
BEGIN_COM_MAP(CContextMenu)
COM_INTERFACE_ENTRY(IShellExtInit)
COM_INTERFACE_ENTRY(IContextMenu)
COM_INTERFACE_ENTRY(IContextMenu2)
COM_INTERFACE_ENTRY(IContextMenu3)
END_COM_MAP()
DECLARE_PROTECT_FINAL_CONSTRUCT()
CContextMenu()
{
RegisterExtension(tszVVVExtension);
}
// Purpose: called by the 'impl' class. Request to configure the menu
void OnQueryContextMenu(IContextMenuImpl<CContextMenu>::CMenu& menu,
const CStrings& filenames)
{
if (ContainsUnknownExtension(filenames))
return; // only extend the menu when only .vvv files are selected.
if (filenames.size() != 1)
return; // only add to the context menu when 1 file is selected.
CCustomMenuHandlerPtr qsmallbitmaphandler(new CSmallBitmapHandler(IDS_CONTEXTMENU_VVV_SUBMENU, IDB_MENUICON));
CMenu menuVVV = menu.AddSubMenu(IDS_CONTEXTMENU_VVV_SUBMENU_HELP, qsmallbitmaphandler);
CContextCommandPtr qeditwithnotepadcommand(new CEditWithNotepadCommand());
menuVVV.AddItem(IDS_CONTEXTMENU_EDIT_WITH_NOTEPAD,
IDS_CONTEXTMENU_EDIT_WITH_NOTEPAD_HELP, qeditwithnotepadcommand);
CContextCommandPtr qaboutmsfcommand(new CAboutMSFCommand());
CCustomMenuHandlerPtr qsmallbitmaphandler2(new CSmallBitmapHandler(IDS_CONTEXTMENU_ABOUT_MSF, IDB_MENUICON));
menuVVV.AddItem(IDS_CONTEXTMENU_ABOUT_MSF_HELP, qaboutmsfcommand, qsmallbitmaphandler2);
// ... optional add more submenu's or more menu items.
}
};
OBJECT_ENTRY_AUTO(__uuidof(CContextMenu), CContextMenu)
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
Victor lives in Nijmegen, the oldest city in The Netherlands.
He studied Applied Physics in Delft and works Hitachi High-Tech Analytical Science.