10
|
1 /* vi:set ts=8 sts=4 sw=4:
|
|
2 *
|
|
3 * VIM - Vi IMproved gvimext by Tianmiao Hu
|
|
4 *
|
|
5 * Do ":help uganda" in Vim to read copying and usage conditions.
|
|
6 * Do ":help credits" in Vim to see a list of people who contributed.
|
|
7 */
|
|
8
|
|
9 /*
|
|
10 * If you have any questions or any suggestions concerning gvimext, please
|
|
11 * contact Tianmiao Hu: tianmiao@acm.org.
|
|
12 */
|
|
13
|
|
14 #if !defined(AFX_STDAFX_H__3389658B_AD83_11D3_9C1E_0090278BBD99__INCLUDED_)
|
|
15 #define AFX_STDAFX_H__3389658B_AD83_11D3_9C1E_0090278BBD99__INCLUDED_
|
|
16
|
|
17 #if _MSC_VER > 1000
|
|
18 #pragma once
|
|
19 #endif // _MSC_VER > 1000
|
|
20
|
|
21 // Insert your headers here
|
|
22 // #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
|
23
|
|
24 //--------------------------------------------------------------
|
|
25 // common user interface routines
|
|
26 //
|
|
27 //
|
|
28 //--------------------------------------------------------------
|
|
29
|
|
30 #ifndef STRICT
|
|
31 #define STRICT
|
|
32 #endif
|
|
33
|
|
34 #define INC_OLE2 // WIN32, get ole2 from windows.h
|
|
35
|
|
36 #include <windows.h>
|
|
37 #include <windowsx.h>
|
|
38 #include <shlobj.h>
|
|
39
|
|
40 #define ResultFromShort(i) ResultFromScode(MAKE_SCODE(SEVERITY_SUCCESS, 0, (USHORT)(i)))
|
|
41
|
|
42 // Initialize GUIDs (should be done only and at-least once per DLL/EXE)
|
|
43 //
|
|
44 #pragma data_seg(".text")
|
|
45 #define INITGUID
|
|
46 #include <initguid.h>
|
|
47 #include <shlguid.h>
|
|
48
|
|
49 //
|
|
50 // The class ID of this Shell extension class.
|
|
51 //
|
|
52 // class id: {51EEE242-AD87-11d3-9C1E-0090278BBD99}
|
|
53 //
|
|
54 //
|
|
55 // NOTE!!! If you use this shell extension as a starting point,
|
|
56 // you MUST change the GUID below. Simply run UUIDGEN.EXE
|
|
57 // to generate a new GUID.
|
|
58 //
|
|
59
|
|
60 // {51EEE242-AD87-11d3-9C1E-0090278BBD99}
|
|
61 // static const GUID <<name>> =
|
|
62 // { 0x51eee242, 0xad87, 0x11d3, { 0x9c, 0x1e, 0x0, 0x90, 0x27, 0x8b, 0xbd, 0x99 } };
|
|
63 //
|
|
64 //
|
|
65
|
|
66 // {51EEE242-AD87-11d3-9C1E-0090278BBD99}
|
|
67 // IMPLEMENT_OLECREATE(<<class>>, <<external_name>>,
|
|
68 // 0x51eee242, 0xad87, 0x11d3, 0x9c, 0x1e, 0x0, 0x90, 0x27, 0x8b, 0xbd, 0x99);
|
|
69 //
|
|
70
|
|
71 // {51EEE242-AD87-11d3-9C1E-0090278BBD99} -- this is the registry format
|
|
72 DEFINE_GUID(CLSID_ShellExtension, 0x51eee242, 0xad87, 0x11d3, 0x9c, 0x1e, 0x0, 0x90, 0x27, 0x8b, 0xbd, 0x99);
|
|
73
|
|
74 // this class factory object creates context menu handlers for windows 32 shell
|
|
75 class CShellExtClassFactory : public IClassFactory
|
|
76 {
|
|
77 protected:
|
|
78 ULONG m_cRef;
|
|
79
|
|
80 public:
|
|
81 CShellExtClassFactory();
|
|
82 ~CShellExtClassFactory();
|
|
83
|
|
84 //IUnknown members
|
|
85 STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
|
|
86 STDMETHODIMP_(ULONG) AddRef();
|
|
87 STDMETHODIMP_(ULONG) Release();
|
|
88
|
|
89 //IClassFactory members
|
|
90 STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, LPVOID FAR *);
|
|
91 STDMETHODIMP LockServer(BOOL);
|
|
92
|
|
93 };
|
|
94 typedef CShellExtClassFactory *LPCSHELLEXTCLASSFACTORY;
|
|
95 #define MAX_HWND 100
|
|
96
|
|
97 // this is the actual OLE Shell context menu handler
|
|
98 class CShellExt : public IContextMenu,
|
|
99 IShellExtInit
|
|
100 {
|
|
101 protected:
|
|
102 ULONG m_cRef;
|
|
103 LPDATAOBJECT m_pDataObj;
|
|
104 UINT m_edit_existing_off;
|
|
105
|
|
106 // For some reason, this callback must be static
|
|
107 static BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam);
|
|
108
|
|
109 STDMETHODIMP PushToWindow(HWND hParent,
|
|
110 LPCSTR pszWorkingDir,
|
|
111 LPCSTR pszCmd,
|
|
112 LPCSTR pszParam,
|
|
113 int iShowCmd,
|
|
114 int idHWnd);
|
|
115
|
|
116 STDMETHODIMP InvokeGvim(HWND hParent,
|
|
117 LPCSTR pszWorkingDir,
|
|
118 LPCSTR pszCmd,
|
|
119 LPCSTR pszParam,
|
|
120 int iShowCmd);
|
|
121
|
|
122 STDMETHODIMP InvokeSingleGvim(HWND hParent,
|
|
123 LPCSTR pszWorkingDir,
|
|
124 LPCSTR pszCmd,
|
|
125 LPCSTR pszParam,
|
|
126 int iShowCmd,
|
|
127 int useDiff);
|
|
128
|
|
129 public:
|
|
130 int m_cntOfHWnd;
|
|
131 HWND m_hWnd[MAX_HWND];
|
|
132 CShellExt();
|
|
133 ~CShellExt();
|
|
134
|
|
135 //IUnknown members
|
|
136 STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
|
|
137 STDMETHODIMP_(ULONG) AddRef();
|
|
138 STDMETHODIMP_(ULONG) Release();
|
|
139
|
|
140 //IShell members
|
|
141 STDMETHODIMP QueryContextMenu(HMENU hMenu,
|
|
142 UINT indexMenu,
|
|
143 UINT idCmdFirst,
|
|
144 UINT idCmdLast,
|
|
145 UINT uFlags);
|
|
146
|
|
147 STDMETHODIMP InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi);
|
|
148
|
|
149 STDMETHODIMP GetCommandString(UINT idCmd,
|
|
150 UINT uFlags,
|
|
151 UINT FAR *reserved,
|
|
152 LPSTR pszName,
|
|
153 UINT cchMax);
|
|
154
|
|
155 //IShellExtInit methods
|
|
156 STDMETHODIMP Initialize(LPCITEMIDLIST pIDFolder,
|
|
157 LPDATAOBJECT pDataObj,
|
|
158 HKEY hKeyID);
|
|
159 };
|
|
160
|
|
161 typedef CShellExt *LPCSHELLEXT;
|
|
162 #pragma data_seg()
|
|
163
|
|
164 #endif
|