blob: d68807320abbfcb3ff023ec45c69931e6de97041 [file] [log] [blame]
Bram Moolenaarf4b8e572004-06-24 15:53:16 +00001/* 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
Bram Moolenaar362e1a32006-03-06 23:29:24 +000036/* Visual Studio 2005 has 'deprecated' many of the standard CRT functions */
37#if _MSC_VER >= 1400
38# define _CRT_SECURE_NO_DEPRECATE
39# define _CRT_NONSTDC_NO_DEPRECATE
40#endif
41
Bram Moolenaarf4b8e572004-06-24 15:53:16 +000042#include <windows.h>
43#include <windowsx.h>
44#include <shlobj.h>
45
46#define ResultFromShort(i) ResultFromScode(MAKE_SCODE(SEVERITY_SUCCESS, 0, (USHORT)(i)))
47
48// Initialize GUIDs (should be done only and at-least once per DLL/EXE)
49//
50#pragma data_seg(".text")
51#define INITGUID
52#include <initguid.h>
53#include <shlguid.h>
54
55//
56// The class ID of this Shell extension class.
57//
58// class id: {51EEE242-AD87-11d3-9C1E-0090278BBD99}
59//
60//
61// NOTE!!! If you use this shell extension as a starting point,
62// you MUST change the GUID below. Simply run UUIDGEN.EXE
63// to generate a new GUID.
64//
65
66// {51EEE242-AD87-11d3-9C1E-0090278BBD99}
67// static const GUID <<name>> =
68// { 0x51eee242, 0xad87, 0x11d3, { 0x9c, 0x1e, 0x0, 0x90, 0x27, 0x8b, 0xbd, 0x99 } };
69//
70//
71
72// {51EEE242-AD87-11d3-9C1E-0090278BBD99}
73// IMPLEMENT_OLECREATE(<<class>>, <<external_name>>,
74// 0x51eee242, 0xad87, 0x11d3, 0x9c, 0x1e, 0x0, 0x90, 0x27, 0x8b, 0xbd, 0x99);
75//
76
77// {51EEE242-AD87-11d3-9C1E-0090278BBD99} -- this is the registry format
78DEFINE_GUID(CLSID_ShellExtension, 0x51eee242, 0xad87, 0x11d3, 0x9c, 0x1e, 0x0, 0x90, 0x27, 0x8b, 0xbd, 0x99);
79
80// this class factory object creates context menu handlers for windows 32 shell
81class CShellExtClassFactory : public IClassFactory
82{
83protected:
84 ULONG m_cRef;
85
86public:
87 CShellExtClassFactory();
88 ~CShellExtClassFactory();
89
90 //IUnknown members
91 STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
92 STDMETHODIMP_(ULONG) AddRef();
93 STDMETHODIMP_(ULONG) Release();
94
95 //IClassFactory members
96 STDMETHODIMP CreateInstance(LPUNKNOWN, REFIID, LPVOID FAR *);
97 STDMETHODIMP LockServer(BOOL);
98
99};
100typedef CShellExtClassFactory *LPCSHELLEXTCLASSFACTORY;
101#define MAX_HWND 100
102
103// this is the actual OLE Shell context menu handler
104class CShellExt : public IContextMenu,
105 IShellExtInit
106{
107protected:
108 ULONG m_cRef;
109 LPDATAOBJECT m_pDataObj;
110 UINT m_edit_existing_off;
111
112 // For some reason, this callback must be static
113 static BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam);
114
115 STDMETHODIMP PushToWindow(HWND hParent,
116 LPCSTR pszWorkingDir,
117 LPCSTR pszCmd,
118 LPCSTR pszParam,
119 int iShowCmd,
120 int idHWnd);
121
122 STDMETHODIMP InvokeGvim(HWND hParent,
123 LPCSTR pszWorkingDir,
124 LPCSTR pszCmd,
125 LPCSTR pszParam,
126 int iShowCmd);
127
128 STDMETHODIMP InvokeSingleGvim(HWND hParent,
129 LPCSTR pszWorkingDir,
130 LPCSTR pszCmd,
131 LPCSTR pszParam,
132 int iShowCmd,
133 int useDiff);
134
135public:
136 int m_cntOfHWnd;
137 HWND m_hWnd[MAX_HWND];
138 CShellExt();
139 ~CShellExt();
140
141 //IUnknown members
142 STDMETHODIMP QueryInterface(REFIID, LPVOID FAR *);
143 STDMETHODIMP_(ULONG) AddRef();
144 STDMETHODIMP_(ULONG) Release();
145
146 //IShell members
147 STDMETHODIMP QueryContextMenu(HMENU hMenu,
148 UINT indexMenu,
149 UINT idCmdFirst,
150 UINT idCmdLast,
151 UINT uFlags);
152
153 STDMETHODIMP InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi);
154
155 STDMETHODIMP GetCommandString(UINT idCmd,
156 UINT uFlags,
157 UINT FAR *reserved,
158 LPSTR pszName,
159 UINT cchMax);
160
161 //IShellExtInit methods
162 STDMETHODIMP Initialize(LPCITEMIDLIST pIDFolder,
163 LPDATAOBJECT pDataObj,
164 HKEY hKeyID);
165};
166
167typedef CShellExt *LPCSHELLEXT;
168#pragma data_seg()
169
170#endif