Synchronize with trunk.
[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 <tchar.h>
22 #include <stdio.h>
23 #include <uxtheme.h>
24
25 #include "tmschema.h"
26 #include "resource.h"
27 #include "comcsup.h"
28 //#include "todo.h"
29 //#include "initguid.h"
30 #include "undoc.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 * traywnd.c
172 */
173
174 #define TWM_OPENSTARTMENU (WM_USER + 260)
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 * settings.c
246 */
247
248 /* Structure to hold non-default options*/
249 typedef struct _ADVANCED_SETTINGS {
250 BOOL bShowSeconds;
251 } ADVANCED_SETTINGS, *PADVANCED_SETTINGS;
252
253 extern ADVANCED_SETTINGS AdvancedSettings;
254 extern const TCHAR szAdvancedSettingsKey[];
255
256 VOID
257 LoadAdvancedSettings(VOID);
258
259 BOOL
260 SaveSettingDword(IN PCTSTR pszKeyName,
261 IN PCTSTR pszValueName,
262 IN DWORD dwValue);
263
264 /*
265 * startup.c
266 */
267
268 int
269 ProcessStartupItems(VOID);
270
271 /*
272 * trayprop.h
273 */
274
275 VOID
276 DisplayTrayProperties(IN HWND hwndOwner);
277
278 /*
279 * desktop.c
280 */
281 HANDLE
282 DesktopCreateWindow(IN OUT ITrayWindow *Tray);
283
284 VOID
285 DesktopDestroyShellWindow(IN HANDLE hDesktop);
286
287 /*
288 * taskband.c
289 */
290
291 /* Internal Task Band CLSID */
292 extern const GUID CLSID_ITaskBand;
293
294 #define INTERFACE ITaskBand
295 DECLARE_INTERFACE_(ITaskBand,IUnknown)
296 {
297 /*** IUnknown methods ***/
298 STDMETHOD_(HRESULT,QueryInterface) (THIS_ REFIID riid, void** ppvObject) PURE;
299 STDMETHOD_(ULONG,AddRef) (THIS) PURE;
300 STDMETHOD_(ULONG,Release) (THIS) PURE;
301 /*** ITaskBand methods ***/
302 STDMETHOD_(HRESULT,GetRebarBandID)(THIS_ DWORD *pdwBandID) PURE;
303 };
304 #undef INTERFACE
305
306 #if defined(COBJMACROS)
307 /*** IUnknown methods ***/
308 #define ITaskBand_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
309 #define ITaskBand_AddRef(p) (p)->lpVtbl->AddRef(p)
310 #define ITaskBand_Release(p) (p)->lpVtbl->Release(p)
311 /*** ITaskBand methods ***/
312 #define ITaskBand_GetRebarBandID(p,a) (p)->lpVtbl->GetRebarBandID(p,a)
313 #endif
314
315 ITaskBand *
316 CreateTaskBand(IN OUT ITrayWindow *Tray);
317
318 /*
319 * tbsite.c
320 */
321
322 #define INTERFACE ITrayBandSite
323 DECLARE_INTERFACE_(ITrayBandSite,IUnknown)
324 {
325 /*** IUnknown methods ***/
326 STDMETHOD_(HRESULT,QueryInterface) (THIS_ REFIID riid, void** ppvObject) PURE;
327 STDMETHOD_(ULONG,AddRef) (THIS) PURE;
328 STDMETHOD_(ULONG,Release) (THIS) PURE;
329 /*** IBandSiteStreamCallback ***/
330 STDMETHOD_(HRESULT,OnLoad)(THIS_ IStream *pStm, REFIID riid, PVOID *pvObj) PURE;
331 STDMETHOD_(HRESULT,OnSave)(THIS_ IUnknown *pUnk, IStream *pStm) PURE;
332 /*** ITrayBandSite methods ***/
333 STDMETHOD_(HRESULT,IsTaskBand) (THIS_ IUnknown *punk) PURE;
334 STDMETHOD_(HRESULT,ProcessMessage) (THIS_ HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *plResult) PURE;
335 STDMETHOD_(HRESULT,AddContextMenus) (THIS_ HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags, IContextMenu **ppcm) PURE;
336 STDMETHOD_(HRESULT,Lock) (THIS_ BOOL bLock) PURE;
337 };
338 #undef INTERFACE
339
340 #if defined(COBJMACROS)
341 /*** IUnknown methods ***/
342 #define ITrayBandSite_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
343 #define ITrayBandSite_AddRef(p) (p)->lpVtbl->AddRef(p)
344 #define ITrayBandSite_Release(p) (p)->lpVtbl->Release(p)
345 /*** IBandSiteStreamCallback methods ***/
346 #define ITrayBandSite_OnLoad(p,a,b,c) (p)->lpVtbl->OnLoad(p,a,b,c)
347 #define ITrayBandSite_OnSave(p,a,b) (p)->lpVtbl->OnSave(p,a,b)
348 /*** ITrayBandSite methods ***/
349 #define ITrayBandSite_IsTaskBand(p,a) (p)->lpVtbl->IsTaskBand(p,a)
350 #define ITrayBandSite_ProcessMessage(p,a,b,c,d,e) (p)->lpVtbl->ProcessMessage(p,a,b,c,d,e)
351 #define ITrayBandSite_AddContextMenus(p,a,b,c,d,e,f) (p)->lpVtbl->AddContextMenus(p,a,b,c,d,e,f)
352 #define ITrayBandSite_Lock(p,a) (p)->lpVtbl->Lock(p,a)
353 #endif
354
355 ITrayBandSite *
356 CreateTrayBandSite(IN OUT ITrayWindow *Tray,
357 OUT HWND *phWndRebar,
358 OUT HWND *phWndTaskSwitch);
359
360 /*
361 * startmnu.c
362 */
363
364 extern const TRAYWINDOW_CTXMENU StartMenuBtnCtxMenu;
365
366 #define INTERFACE IStartMenuSite
367 DECLARE_INTERFACE_(IStartMenuSite,IUnknown)
368 {
369 /*** IUnknown methods ***/
370 STDMETHOD_(HRESULT,QueryInterface) (THIS_ REFIID riid, void** ppvObject) PURE;
371 STDMETHOD_(ULONG,AddRef) (THIS) PURE;
372 STDMETHOD_(ULONG,Release) (THIS) PURE;
373 /*** IStartMenuSite ***/
374 };
375 #undef INTERFACE
376
377 #if defined(COBJMACROS)
378 /*** IUnknown methods ***/
379 #define IStartMenuSite_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
380 #define IStartMenuSite_AddRef(p) (p)->lpVtbl->AddRef(p)
381 #define IStartMenuSite_Release(p) (p)->lpVtbl->Release(p)
382 /*** IStartMenuSite methods ***/
383 #endif
384
385 IMenuPopup*
386 CreateStartMenu(IN ITrayWindow *Tray,
387 OUT IMenuBand **ppMenuBand,
388 IN HBITMAP hbmBanner OPTIONAL,
389 IN BOOL bSmallIcons);
390
391 HRESULT
392 UpdateStartMenu(IN OUT IMenuPopup *pMenuPopup,
393 IN HBITMAP hbmBanner OPTIONAL,
394 IN BOOL bSmallIcons);
395
396 /*
397 * trayntfy.c
398 */
399
400 /* TrayClockWnd */
401 #define TCWM_GETMINIMUMSIZE (WM_USER + 0x100)
402 #define TCWM_UPDATETIME (WM_USER + 0x101)
403
404 /* TrayNotifyWnd */
405 #define TNWM_GETMINIMUMSIZE (WM_USER + 0x100)
406 #define TNWM_UPDATETIME (WM_USER + 0x101)
407 #define TNWM_SHOWCLOCK (WM_USER + 0x102)
408 #define TNWM_SHOWTRAY (WM_USER + 0x103)
409 #define TNWM_CHANGETRAYPOS (WM_USER + 0x104)
410
411 #define NTNWM_REALIGN (0x1)
412
413 BOOL
414 RegisterTrayNotifyWndClass(VOID);
415
416 VOID
417 UnregisterTrayNotifyWndClass(VOID);
418
419 HWND
420 CreateTrayNotifyWnd(IN OUT ITrayWindow *TrayWindow,
421 IN BOOL bHideClock);
422
423 VOID
424 TrayNotify_NotifyMsg(IN HWND hwnd,
425 IN WPARAM wParam,
426 IN LPARAM lParam);
427
428 BOOL
429 TrayNotify_GetClockRect(IN HWND hwnd,
430 OUT PRECT rcClock);
431
432 /*
433 * taskswnd.c
434 */
435
436 #define TSWM_ENABLEGROUPING (WM_USER + 1)
437 #define TSWM_UPDATETASKBARPOS (WM_USER + 2)
438
439 BOOL
440 RegisterTaskSwitchWndClass(VOID);
441
442 VOID
443 UnregisterTaskSwitchWndClass(VOID);
444
445 HWND
446 CreateTaskSwitchWnd(IN HWND hWndParent,
447 IN OUT ITrayWindow *Tray);
448
449 #endif /* _EXPLORER_PRECOMP__H_ */