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