source: branches/erasershellext/cpp/CtxMenu.h @ 441

Revision 441, 2.9 KB checked in by cjax, 6 years ago (diff)

C++: Eraser Shell Extension added

Line 
1// CtxMenu.h : Declaration of the CCtxMenu
2
3#pragma once
4#include "resource.h"       // main symbols
5
6#include "EraserCtxMenu_i.h"
7
8
9#if defined(_WIN32_WCE) && !defined(_CE_DCOM) && !defined(_CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA)
10#error "Single-threaded COM objects are not properly supported on Windows CE platform, such as the Windows Mobile platforms that do not include full DCOM support. Define _CE_ALLOW_SINGLE_THREADED_OBJECTS_IN_MTA to force ATL to support creating single-thread COM object's and allow use of it's single-threaded COM object implementations. The threading model in your rgs file was set to 'Free' as that is the only threading model supported in non DCOM Windows CE platforms."
11#endif
12
13#include <string>
14#include <list>
15
16
17#define CERASER_ENUM_TYPE       unsigned short
18#define CERASER_CAST(type,x)    ((type)(x))
19#define CERASER_ENUM(x)         (CERASER_CAST(CERASER_ENUM_TYPE,x))
20
21#define private()   private:
22#define public()    public:
23#define protected() protected:
24#define nullpointer(type) ((type)0)
25
26#ifdef __cplusplus0x
27#define CERASER_ENUM_CPP0X          : CERASER_ENUM_TYPE
28#elif defined(__cplusplus)
29#define CERASER_ENUM_CPP0X 
30#else
31#error This is a template C++ file!
32#endif
33
34#ifdef _DEBUG
35#define DebugMessageBox(...) MessageBox(__VA_ARGS__)
36static HWND DebugHWND =
37CreateWindow(0, _T("Eraser Debug Windows", "Eraser Debug Windows"), 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL);
38#else
39#define DebugMessageBox(...) ;;;;;;;;;;;;;;;;;;;;;;;
40#endif
41
42namespace Eraser
43{
44    typedef std::list<std::basic_string<WCHAR> > string_list;
45
46    // CCtxMenu
47
48    class ATL_NO_VTABLE CCtxMenu :
49        public CComObjectRootEx<CComSingleThreadModel>,
50        public CComCoClass<CCtxMenu, &CLSID_CtxMenu>,
51        public ICtxMenu,
52        public IShellExtInit,
53        public IContextMenu
54    {
55    public:
56        CCtxMenu()
57        {
58        }
59
60        public() enum CEraserLPVERB CERASER_ENUM_CPP0X
61        {
62            LPVERB_FRIST                    = 0x8000, // 16-bit enum hack
63            LPVERB_SHOW_FILE_NAME                   ,
64            LPVERB_ERASE_FREE_SPACE                 ,
65            LPVERB_ERASE_FILE                       ,
66            LPVERB_SET_FREE_SPACE_ALGORITHM         ,
67            LPVERB_SET_FILE_ALGORITHM               ,
68            LPVERB_SET_DEFAULT_FREE_SPACE_ALGORITHM ,
69            LPVERB_SET_DEFAULT_FILE_ALGORITHM       ,   
70            LPVERB_LAST,
71        };
72    public:
73        // IShellExtInit
74        STDMETHOD(Initialize)(LPCITEMIDLIST, LPDATAOBJECT, HKEY);
75
76        // IContextMenu
77        STDMETHOD(GetCommandString)(UINT, UINT, UINT*, LPSTR, UINT);
78        STDMETHOD(InvokeCommand)(LPCMINVOKECOMMANDINFO);
79        STDMETHOD(QueryContextMenu)(HMENU, UINT, UINT, UINT, UINT);
80
81    protected:
82        string_list m_szSelectedFiles;
83        HBITMAP*    m_szEraserIcon;
84    public:
85
86    DECLARE_REGISTRY_RESOURCEID(IDR_CTXMENU)
87
88    DECLARE_NOT_AGGREGATABLE(CCtxMenu)
89
90    BEGIN_COM_MAP(CCtxMenu)
91        COM_INTERFACE_ENTRY(ICtxMenu)
92    END_COM_MAP()
93
94        DECLARE_PROTECT_FINAL_CONSTRUCT()
95
96        HRESULT FinalConstruct()
97        {
98            return S_OK;
99        }
100
101        void FinalRelease()
102        {
103        }
104    };
105
106    OBJECT_ENTRY_AUTO(__uuidof(CtxMenu), CCtxMenu)
107
108} // namespace Eraser
Note: See TracBrowser for help on using the repository browser.