The following C++ code snippet demonstrates the structure of the shortcut menu extension component class definition.
Code Example
The following code example demonstrates how to implement IContextMenu and IObjectWithSite.
Note: |
|---|
| To make the following code example easier to read, security checking and error handling are not included. This code example should not be used in a release configuration unless it has been modified to include them. |
Copy Code | |
|---|---|
class CMyComp : public IContextMenu, IObjectWithSite
{
public:
CMyComp(); // Constructor.
~CMyComp(); // Destructor.
// IUnknown methods.
STDMETHOD (QueryInterface) (REFIID riid, LPVOID *ppv);
STDMETHOD_(ULONG, AddRef) (void);
STDMETHOD_(ULONG Release) (void);
// IContextMenu methods.
STDMETHOD (GetCommandString) (UINT idCmd, UINT uFlags,
UINT *pwReserved,LPSTR pszName, UINT cchMx);
STDMETHOD (InvokeCommand) (LPCMINVOKECOMMANDINFO pici);
STDMETHOD (QueryContextMenu) (hmenu, UINT indexMenu,
UINT idCmdFirs, UINT idCmdLast, UINT uFlags);
// IObjectWithSite methods.
STDMETHOD (GetSite) (REFIID riid, void **ppvSite);
STDMETHOD (SetSite) (IUnknown *pUnkSite);
// CMyComp methods.
// None.
protected:
ULONG m_cRef; // Reference count.
IUnknown m_punkSite; // Site (owner) pointer.
}; | |
See Also
Note: