OSDN Git Service

PATCH: [ 1258270 ] ShellExtension: allow re-selecting first item
[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 // RCS ID line follows -- this is updated by CVS
25 // $Id$
26
27 #ifndef __WINMERGESHELL_H_
28 #define __WINMERGESHELL_H_
29
30 #include <shlobj.h>
31 #include <comdef.h>
32 #include <atlconv.h>    // for ATL string conversion macros
33 #include "resource.h"   // main symbols
34
35 /** 
36  * @brief Class for handling shell extension tasks
37  */
38 class ATL_NO_VTABLE CWinMergeShell : 
39         public CComObjectRootEx<CComSingleThreadModel>,
40         public CComCoClass<CWinMergeShell, &CLSID_WinMergeShell>,
41         public IDispatchImpl<IWinMergeShell, &IID_IWinMergeShell, &LIBID_SHELLEXTENSIONLib>,
42         public IShellExtInit,
43         public IContextMenu
44 {
45 public:
46         CWinMergeShell();
47
48 DECLARE_REGISTRY_RESOURCEID(IDR_WINMERGESHELL)
49
50 DECLARE_PROTECT_FINAL_CONSTRUCT()
51
52 BEGIN_COM_MAP(CWinMergeShell)
53         COM_INTERFACE_ENTRY(IWinMergeShell)
54         COM_INTERFACE_ENTRY(IDispatch)
55         COM_INTERFACE_ENTRY(IShellExtInit)
56         COM_INTERFACE_ENTRY(IContextMenu)
57 END_COM_MAP()
58
59 // IWinMergeShell
60 protected:
61     CString m_strPaths[2]; /**< Paths for selected items */
62         CString m_strPreviousPath; /**< Previously selected path */
63         HBITMAP m_hMergeBmp; /**< Icon */
64         UINT m_nSelectedItems; /**< Amount of selected items */
65         DWORD m_dwContextMenuEnabled; /**< Is context menu enabled and in which mode? */
66         DWORD m_dwMenuState; /**< Shown menuitems */
67
68         BOOL GetWinMergeDir(CString &strDir);
69         BOOL CheckExecutable(CString path);
70         int DrawSimpleMenu(HMENU hmenu, UINT uMenuIndex, UINT uidFirstCmd);
71         int DrawAdvancedMenu(HMENU hmenu, UINT uMenuIndex, UINT uidFirstCmd);
72         CString GetHelpText(int idCmd);
73         CString FormatCmdLine(const CString &winmergePath,
74                 const CString &path1, const CString &path2);
75
76 public:
77     // IShellExtInit
78     STDMETHOD(Initialize)(LPCITEMIDLIST, LPDATAOBJECT, HKEY);
79
80     // IContextMenu
81     STDMETHOD(GetCommandString)(UINT, UINT, UINT*, LPSTR, UINT);
82     STDMETHOD(InvokeCommand)(LPCMINVOKECOMMANDINFO);
83     STDMETHOD(QueryContextMenu)(HMENU, UINT, UINT, UINT, UINT);
84 };
85
86 #endif //__WINMERGESHELL_H_