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