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