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