OSDN Git Service

e70b2503d147850f9d774115cafce1f812b2d2f3
[winmerge-jp/winmerge-jp.git] / ShellExtension / WinMergeShell.h
1 /////////////////////////////////////////////////////////////////////////////
2 //    License (GPLv2+):
3 //    This program is free software; you can redistribute it and/or modify
4 //    it under the terms of the GNU General Public License as published by
5 //    the Free Software Foundation; either version 2 of the License, or (at
6 //    your option) any later version.
7 //
8 //    This program is distributed in the hope that it will be useful, but
9 //    WITHOUT ANY WARRANTY; without even the implied warranty of
10 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11 //    GNU General Public License for more details.
12 //
13 //    You should have received a copy of the GNU General Public License
14 //    along with this program; if not, write to the Free Software
15 //    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
16 /////////////////////////////////////////////////////////////////////////////
17 // Look at http://www.codeproject.com/shell/ for excellent guide
18 // to Windows Shell programming by Michael Dunn.
19 /**
20  * @file  WinMergeShell.h
21  *
22  * @brief Declaration file for ShellExtension class
23  */
24 // ID line follows -- this is updated by SVN
25 // $Id: WinMergeShell.h 6933 2009-07-26 14:07:03Z kimmov $
26
27 #pragma once
28
29 #include <shlobj.h>
30 #include <shlguid.h>
31 #include <comdef.h>
32 #include <atlconv.h>    // for ATL string conversion macros
33 #include "resource.h"   // main symbols
34 #include "UnicodeString.h"
35 #include "LanguageSelect.h"
36
37 /**
38  * @brief Class for handling shell extension tasks
39  */
40 class ATL_NO_VTABLE CWinMergeShell :
41                 public CComObjectRootEx<CComSingleThreadModel>,
42                 public CComCoClass<CWinMergeShell, &CLSID_WinMergeShell>,
43                 public IDispatchImpl<IWinMergeShell, &IID_IWinMergeShell, &LIBID_SHELLEXTENSIONLib>,
44                 public IShellExtInit,
45                 public IContextMenu
46 {
47 public:
48         CWinMergeShell();
49         ~CWinMergeShell();
50
51         DECLARE_REGISTRY_RESOURCEID(IDR_WINMERGESHELL)
52
53         DECLARE_PROTECT_FINAL_CONSTRUCT()
54
55         BEGIN_COM_MAP(CWinMergeShell)
56         COM_INTERFACE_ENTRY(IWinMergeShell)
57         COM_INTERFACE_ENTRY(IDispatch)
58         COM_INTERFACE_ENTRY(IShellExtInit)
59         COM_INTERFACE_ENTRY(IContextMenu)
60         END_COM_MAP()
61
62 // IWinMergeShell
63 protected:
64         String m_strPaths[3]; /**< Paths for selected items */
65         String m_strPreviousPath[2]; /**< Previously selected path */
66         HBITMAP m_MergeBmp, m_MergeDirBmp; /**< Icon */
67         UINT m_nSelectedItems; /**< Amount of selected items */
68         DWORD m_dwContextMenuEnabled; /**< Is context menu enabled and in which mode? */
69         DWORD m_dwMenuState; /**< Shown menuitems */
70         LANGID m_langID; /**< Current Language Id */
71         inline static HMENU s_hMenuLastAdded = nullptr;
72         inline static UINT s_uidCmdLastAdded = 0;
73         inline static CLanguageSelect *s_pLang = nullptr;
74
75         BOOL GetWinMergeDir(String &strDir);
76         int DrawSimpleMenu(HMENU hmenu, UINT uMenuIndex, UINT uidFirstCmd);
77         int DrawAdvancedMenu(HMENU hmenu, UINT uMenuIndex, UINT uidFirstCmd);
78         String GetHelpText(UINT_PTR idCmd);
79         String FormatCmdLine(const String &winmergePath,
80                         const String &path1, const String &path2, const String &path3, BOOL bAlterSubFolders);
81         String GetResourceString(UINT resourceID);
82         BOOL InsertMenuString(HMENU hMenu, UINT uPosition, UINT uIDNewItem, UINT uStringId);
83
84 public:
85         // IShellExtInit
86         STDMETHOD(Initialize)(LPCITEMIDLIST, LPDATAOBJECT, HKEY);
87
88         // IContextMenu
89         STDMETHOD(GetCommandString)(UINT_PTR, UINT, UINT*, LPSTR, UINT);
90         STDMETHOD(InvokeCommand)(LPCMINVOKECOMMANDINFO);
91         STDMETHOD(QueryContextMenu)(HMENU, UINT, UINT, UINT, UINT);
92 };
93