Added comctl32.ocx, KDEWin, Mono, .net, Media Player Classic, Python, Steam, Tahoma...
[reactos.git] / reactos / base / shell / explorer-new / precomp.h
1 #ifndef _EXPLORER_PRECOMP__H_
2 #define _EXPLORER_PRECOMP__H_
3 #define COBJMACROS
4 #include <windows.h>
5 #include <commctrl.h>
6 #include <oleidl.h>
7 #include <ole2.h>
8 #include <shlobj.h>
9 #include <shlobj_undoc.h>
10 #include <shlwapi.h>
11 #include <servprov.h>
12 #include <shlguid.h>
13 #include <shlguid_undoc.h>
14 #include <ocidl.h>
15 #include <objidl.h>
16 #include <docobj.h>
17 #include <tchar.h>
18 #include <stdio.h>
19 #include <stdlib.h>
20
21 #include "resource.h"
22 #include "comcsup.h"
23 #include "todo.h"
24 #include "initguid.h"
25 #include "undoc.h"
26
27 /* dynamic imports due to lack of support in msvc linker libs */
28 typedef INT (APIENTRY *REGSHELLHOOK)(HWND, DWORD);
29 #ifdef UNICODE
30 #define PROC_NAME_DRAWCAPTIONTEMP "DrawCaptionTempW"
31 typedef BOOL (APIENTRY *DRAWCAPTEMP)(HWND, HDC, const RECT*, HFONT, HICON, LPCWSTR, UINT);
32 #else
33 #define PROC_NAME_DRAWCAPTIONTEMP "DrawCaptionTempA"
34 typedef BOOL (APIENTRY *DRAWCAPTEMP)(HWND, HDC, const RECT*, HFONT, HICON, LPCSTR, UINT);
35 #endif
36 typedef HRESULT (APIENTRY *SHINVDEFCMD)(HWND, IShellFolder*, LPCITEMIDLIST);
37 typedef void (APIENTRY *RUNFILEDLG)(HWND, HICON, LPCWSTR, LPCWSTR, LPCWSTR, UINT);
38 typedef void (APIENTRY *EXITWINDLG)(HWND);
39 typedef HRESULT (APIENTRY *SHWINHELP)(HWND, LPWSTR, UINT, DWORD);
40
41 /* Constants for RunFileDlg */
42 #define RFF_CALCDIRECTORY 0x04 /* Calculates the working directory from the file name. */
43
44 static __inline ULONG
45 Win32DbgPrint(const char *filename, int line, const char *lpFormat, ...)
46 {
47 char szMsg[512];
48 char *szMsgStart;
49 const char *fname;
50 va_list vl;
51 ULONG uRet;
52
53 fname = strrchr(filename, '\\');
54 if (fname == NULL)
55 {
56 fname = strrchr(filename, '/');
57 if (fname != NULL)
58 fname++;
59 }
60 else
61 fname++;
62
63 if (fname == NULL)
64 fname = filename;
65
66 szMsgStart = szMsg + sprintf(szMsg, "%s:%d: ", fname, line);
67
68 va_start(vl, lpFormat);
69 uRet = (ULONG)vsprintf(szMsgStart, lpFormat, vl);
70 va_end(vl);
71
72 OutputDebugStringA(szMsg);
73
74 return uRet;
75 }
76
77 #define ASSERT(cond) \
78 if (!(cond)) { \
79 Win32DbgPrint(__FILE__, __LINE__, "ASSERTION %s FAILED!\n", #cond); \
80 }
81
82 #define DbgPrint(fmt, ...) \
83 Win32DbgPrint(__FILE__, __LINE__, fmt, ##__VA_ARGS__);
84
85 extern HINSTANCE hExplorerInstance;
86 extern HMODULE hUser32;
87 extern HANDLE hProcessHeap;
88 extern HKEY hkExplorer;
89 extern DRAWCAPTEMP DrawCapTemp;
90
91 /*
92 * dragdrop.c
93 */
94
95 typedef struct _DROPTARGET_CALLBACKS
96 {
97 HRESULT (*OnDragEnter)(IN IDropTarget *pDropTarget,
98 IN PVOID Context,
99 IN const FORMATETC *Format,
100 IN DWORD grfKeyState,
101 IN POINTL pt,
102 IN OUT DWORD *pdwEffect);
103 HRESULT (*OnDragOver)(IN IDropTarget *pDropTarget,
104 IN PVOID Context,
105 IN DWORD grfKeyState,
106 IN POINTL pt,
107 IN OUT DWORD *pdwEffect);
108 HRESULT (*OnDragLeave)(IN IDropTarget *pDropTarget,
109 IN PVOID Context);
110 HRESULT (*OnDrop)(IN IDropTarget *pDropTarget,
111 IN PVOID Context,
112 IN const FORMATETC *Format,
113 IN DWORD grfKeyState,
114 IN POINTL pt,
115 IN OUT DWORD *pdwEffect);
116 } DROPTARGET_CALLBACKS, *PDROPTARGET_CALLBACKS;
117
118 IDropTarget *
119 CreateDropTarget(IN HWND hwndTarget,
120 IN DWORD nSupportedFormats,
121 IN const FORMATETC *Formats OPTIONAL,
122 IN PVOID Context OPTIONAL,
123 IN const DROPTARGET_CALLBACKS *Callbacks OPTIONAL);
124
125 /*
126 * explorer.c
127 */
128
129 LONG
130 SetWindowStyle(IN HWND hWnd,
131 IN LONG dwStyleMask,
132 IN LONG dwStyle);
133
134 LONG
135 SetWindowExStyle(IN HWND hWnd,
136 IN LONG dwStyleMask,
137 IN LONG dwStyle);
138
139 HMENU
140 LoadPopupMenu(IN HINSTANCE hInstance,
141 IN LPCTSTR lpMenuName);
142
143 HMENU
144 FindSubMenu(IN HMENU hMenu,
145 IN UINT uItem,
146 IN BOOL fByPosition);
147
148 BOOL
149 GetCurrentLoggedOnUserName(OUT LPTSTR szBuffer,
150 IN DWORD dwBufferSize);
151
152 BOOL
153 FormatMenuString(IN HMENU hMenu,
154 IN UINT uPosition,
155 IN UINT uFlags,
156 ...);
157
158 BOOL
159 GetExplorerRegValueSet(IN HKEY hKey,
160 IN LPCTSTR lpSubKey,
161 IN LPCTSTR lpValue);
162
163 /*
164 * traywnd.c
165 */
166
167 typedef HMENU (*PCREATECTXMENU)(IN HWND hWndOwner,
168 IN PVOID *ppcmContext,
169 IN PVOID Context OPTIONAL);
170 typedef VOID (*PCTXMENUCOMMAND)(IN HWND hWndOwner,
171 IN UINT uiCmdId,
172 IN PVOID pcmContext OPTIONAL,
173 IN PVOID Context OPTIONAL);
174
175 typedef struct _TRAYWINDOW_CTXMENU
176 {
177 PCREATECTXMENU CreateCtxMenu;
178 PCTXMENUCOMMAND CtxMenuCommand;
179 } TRAYWINDOW_CTXMENU, *PTRAYWINDOW_CTXMENU;
180
181 extern const GUID IID_IShellDesktopTray;
182
183 #define INTERFACE ITrayWindow
184 DECLARE_INTERFACE_(ITrayWindow,IUnknown)
185 {
186 /*** IUnknown methods ***/
187 STDMETHOD_(HRESULT,QueryInterface) (THIS_ REFIID riid, void** ppvObject) PURE;
188 STDMETHOD_(ULONG,AddRef) (THIS) PURE;
189 STDMETHOD_(ULONG,Release) (THIS) PURE;
190 /*** ITrayWindow methods ***/
191 STDMETHOD_(HRESULT,Open) (THIS) PURE;
192 STDMETHOD_(HRESULT,Close) (THIS) PURE;
193 STDMETHOD_(HWND,GetHWND) (THIS) PURE;
194 STDMETHOD_(BOOL,IsSpecialHWND) (THIS_ HWND hWnd) PURE;
195 STDMETHOD_(BOOL,IsHorizontal) (THIS) PURE;
196 STDMETHOD_(HFONT,GetCaptionFonts) (THIS_ HFONT *phBoldCaption) PURE;
197 STDMETHOD_(HWND,DisplayProperties) (THIS) PURE;
198 STDMETHOD_(BOOL,ExecContextMenuCmd) (THIS_ UINT uiCmd) PURE;
199 STDMETHOD_(BOOL,Lock) (THIS_ BOOL bLock) PURE;
200 };
201 #undef INTERFACE
202
203 #if defined(COBJMACROS)
204 /*** IUnknown methods ***/
205 #define ITrayWindow_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
206 #define ITrayWindow_AddRef(p) (p)->lpVtbl->AddRef(p)
207 #define ITrayWindow_Release(p) (p)->lpVtbl->Release(p)
208 /*** ITrayWindow methods ***/
209 #define ITrayWindow_Open(p) (p)->lpVtbl->Open(p)
210 #define ITrayWindow_Close(p) (p)->lpVtbl->Close(p)
211 #define ITrayWindow_GetHWND(p) (p)->lpVtbl->GetHWND(p)
212 #define ITrayWindow_IsSpecialHWND(p,a) (p)->lpVtbl->IsSpecialHWND(p,a)
213 #define ITrayWindow_IsHorizontal(p) (p)->lpVtbl->IsHorizontal(p)
214 #define ITrayWindow_GetCaptionFonts(p,a) (p)->lpVtbl->GetCaptionFonts(p,a)
215 #define ITrayWindow_DisplayProperties(p) (p)->lpVtbl->DisplayProperties(p)
216 #define ITrayWindow_ExecContextMenuCmd(p,a) (p)->lpVtbl->ExecContextMenuCmd(p,a)
217 #define ITrayWindow_Lock(p,a) (p)->lpVtbl->Lock(p,a)
218 #endif
219
220 BOOL
221 RegisterTrayWindowClass(VOID);
222
223 VOID
224 UnregisterTrayWindowClass(VOID);
225
226 ITrayWindow *
227 CreateTrayWindow(VOID);
228
229 VOID
230 TrayProcessMessages(IN OUT ITrayWindow *Tray);
231
232 VOID
233 TrayMessageLoop(IN OUT ITrayWindow *Tray);
234
235 /*
236 * trayprop.h
237 */
238
239 HWND
240 DisplayTrayProperties(ITrayWindow *Tray);
241
242 /*
243 * desktop.c
244 */
245 HANDLE
246 DesktopCreateWindow(IN OUT ITrayWindow *Tray);
247
248 VOID
249 DesktopDestroyShellWindow(IN HANDLE hDesktop);
250
251 /*
252 * taskband.c
253 */
254
255 /* Internal Task Band CLSID */
256 extern const GUID CLSID_ITaskBand;
257
258 #define INTERFACE ITaskBand
259 DECLARE_INTERFACE_(ITaskBand,IUnknown)
260 {
261 /*** IUnknown methods ***/
262 STDMETHOD_(HRESULT,QueryInterface) (THIS_ REFIID riid, void** ppvObject) PURE;
263 STDMETHOD_(ULONG,AddRef) (THIS) PURE;
264 STDMETHOD_(ULONG,Release) (THIS) PURE;
265 /*** ITaskBand methods ***/
266 STDMETHOD_(HRESULT,GetRebarBandID)(THIS_ DWORD *pdwBandID) PURE;
267 };
268 #undef INTERFACE
269
270 #if defined(COBJMACROS)
271 /*** IUnknown methods ***/
272 #define ITaskBand_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
273 #define ITaskBand_AddRef(p) (p)->lpVtbl->AddRef(p)
274 #define ITaskBand_Release(p) (p)->lpVtbl->Release(p)
275 /*** ITaskBand methods ***/
276 #define ITaskBand_GetRebarBandID(p,a) (p)->lpVtbl->GetRebarBandID(p,a)
277 #endif
278
279 ITaskBand *
280 CreateTaskBand(IN OUT ITrayWindow *Tray);
281
282 /*
283 * tbsite.c
284 */
285
286 #define INTERFACE ITrayBandSite
287 DECLARE_INTERFACE_(ITrayBandSite,IUnknown)
288 {
289 /*** IUnknown methods ***/
290 STDMETHOD_(HRESULT,QueryInterface) (THIS_ REFIID riid, void** ppvObject) PURE;
291 STDMETHOD_(ULONG,AddRef) (THIS) PURE;
292 STDMETHOD_(ULONG,Release) (THIS) PURE;
293 /*** IBandSiteStreamCallback ***/
294 STDMETHOD_(HRESULT,OnLoad)(THIS_ IStream *pStm, REFIID riid, PVOID *pvObj) PURE;
295 STDMETHOD_(HRESULT,OnSave)(THIS_ IUnknown *pUnk, IStream *pStm) PURE;
296 /*** ITrayBandSite methods ***/
297 STDMETHOD_(HRESULT,IsTaskBand) (THIS_ IUnknown *punk) PURE;
298 STDMETHOD_(HRESULT,ProcessMessage) (THIS_ HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *plResult) PURE;
299 STDMETHOD_(HRESULT,AddContextMenus) (THIS_ HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags, IContextMenu **ppcm) PURE;
300 STDMETHOD_(HRESULT,Lock) (THIS_ BOOL bLock) PURE;
301 };
302 #undef INTERFACE
303
304 #if defined(COBJMACROS)
305 /*** IUnknown methods ***/
306 #define ITrayBandSite_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
307 #define ITrayBandSite_AddRef(p) (p)->lpVtbl->AddRef(p)
308 #define ITrayBandSite_Release(p) (p)->lpVtbl->Release(p)
309 /*** IBandSiteStreamCallback methods ***/
310 #define ITrayBandSite_OnLoad(p,a,b,c) (p)->lpVtbl->OnLoad(p,a,b,c)
311 #define ITrayBandSite_OnSave(p,a,b) (p)->lpVtbl->OnSave(p,a,b)
312 /*** ITrayBandSite methods ***/
313 #define ITrayBandSite_IsTaskBand(p,a) (p)->lpVtbl->IsTaskBand(p,a)
314 #define ITrayBandSite_ProcessMessage(p,a,b,c,d,e) (p)->lpVtbl->ProcessMessage(p,a,b,c,d,e)
315 #define ITrayBandSite_AddContextMenus(p,a,b,c,d,e,f) (p)->lpVtbl->AddContextMenus(p,a,b,c,d,e,f)
316 #define ITrayBandSite_Lock(p,a) (p)->lpVtbl->Lock(p,a)
317 #endif
318
319 ITrayBandSite *
320 CreateTrayBandSite(IN OUT ITrayWindow *Tray,
321 OUT HWND *phWndRebar,
322 OUT HWND *phWndTaskSwitch);
323
324 /*
325 * startmnu.c
326 */
327
328 extern const TRAYWINDOW_CTXMENU StartMenuBtnCtxMenu;
329
330 #define INTERFACE IStartMenuSite
331 DECLARE_INTERFACE_(IStartMenuSite,IUnknown)
332 {
333 /*** IUnknown methods ***/
334 STDMETHOD_(HRESULT,QueryInterface) (THIS_ REFIID riid, void** ppvObject) PURE;
335 STDMETHOD_(ULONG,AddRef) (THIS) PURE;
336 STDMETHOD_(ULONG,Release) (THIS) PURE;
337 /*** IStartMenuSite ***/
338 };
339 #undef INTERFACE
340
341 #if defined(COBJMACROS)
342 /*** IUnknown methods ***/
343 #define IStartMenuSite_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
344 #define IStartMenuSite_AddRef(p) (p)->lpVtbl->AddRef(p)
345 #define IStartMenuSite_Release(p) (p)->lpVtbl->Release(p)
346 /*** IStartMenuSite methods ***/
347 #endif
348
349 IMenuPopup*
350 CreateStartMenu(IN ITrayWindow *Tray,
351 OUT IMenuBand **ppMenuBand,
352 IN HBITMAP hbmBanner OPTIONAL,
353 IN BOOL bSmallIcons);
354
355 HRESULT
356 UpdateStartMenu(IN OUT IMenuPopup *pMenuPopup,
357 IN HBITMAP hbmBanner OPTIONAL,
358 IN BOOL bSmallIcons);
359
360 /*
361 * trayntfy.c
362 */
363
364 /* TrayClockWnd */
365 #define TCWM_GETMINIMUMSIZE (WM_USER + 0x100)
366 #define TCWM_UPDATETIME (WM_USER + 0x101)
367
368 /* TrayNotifyWnd */
369 #define TNWM_GETMINIMUMSIZE (WM_USER + 0x100)
370 #define TNWM_UPDATETIME (WM_USER + 0x101)
371 #define TNWM_SHOWCLOCK (WM_USER + 0x102)
372 #define TNWM_SHOWTRAY (WM_USER + 0x103)
373 #define TNWM_CHANGETRAYPOS (WM_USER + 0x104)
374
375 #define NTNWM_REALIGN (0x1)
376
377 BOOL
378 RegisterTrayNotifyWndClass(VOID);
379
380 VOID
381 UnregisterTrayNotifyWndClass(VOID);
382
383 HWND
384 CreateTrayNotifyWnd(IN OUT ITrayWindow *TrayWindow,
385 IN BOOL bHideClock);
386
387 /*
388 * taskswnd.c
389 */
390
391 #define TSWM_ENABLEGROUPING (WM_USER + 1)
392 #define TSWM_UPDATETASKBARPOS (WM_USER + 2)
393
394 BOOL
395 RegisterTaskSwitchWndClass(VOID);
396
397 VOID
398 UnregisterTaskSwitchWndClass(VOID);
399
400 HWND
401 CreateTaskSwitchWnd(IN HWND hWndParent,
402 IN OUT ITrayWindow *Tray);
403
404 #endif /* _EXPLORER_PRECOMP__H_ */