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