[EXPLORER]
[reactos.git] / reactos / base / shell / explorer / precomp.h
1 #ifndef _EXPLORER_PRECOMP__H_
2 #define _EXPLORER_PRECOMP__H_
3
4 #define WIN7_COMPAT_MODE 0
5 #define WIN7_DEBUG_MODE 0
6
7 #if WIN7_DEBUG_MODE && !WIN7_COMPAT_MODE
8 #undef WIN7_COMPAT_MODE
9 #define WIN7_COMPAT_MODE 1
10 #endif
11
12 #include <stdio.h>
13 #include <tchar.h>
14
15 #define WIN32_NO_STATUS
16 #define _INC_WINDOWS
17 #define COM_NO_WINDOWS_H
18
19 #define COBJMACROS
20
21 #include <windef.h>
22 #include <winbase.h>
23 #include <winreg.h>
24 #include <wingdi.h>
25 #include <winnls.h>
26 #include <wincon.h>
27 #include <atlbase.h>
28 #include <atlcom.h>
29 #include <atlwin.h>
30 #include <shellapi.h>
31 #include <shlobj.h>
32 #include <shlwapi.h>
33 #include <uxtheme.h>
34 #include <strsafe.h>
35
36 #include <undocuser.h>
37 #include <shlwapi_undoc.h>
38 #include <shlobj_undoc.h>
39 #include <shlguid_undoc.h>
40 #include <undocshell.h>
41
42 #include <rosctrls.h>
43 #include <shellutils.h>
44
45 #include "tmschema.h"
46 #include "resource.h"
47
48 #include <wine/debug.h>
49
50 WINE_DEFAULT_DEBUG_CHANNEL(explorernew);
51
52 #define ASSERT(cond) \
53 do if (!(cond)) { \
54 Win32DbgPrint(__FILE__, __LINE__, "ASSERTION %s FAILED!\n", #cond); \
55 } while (0)
56
57 extern HINSTANCE hExplorerInstance;
58 extern HANDLE hProcessHeap;
59 extern HKEY hkExplorer;
60
61 /*
62 * explorer.c
63 */
64
65 static inline
66 LONG
67 SetWindowStyle(IN HWND hWnd,
68 IN LONG dwStyleMask,
69 IN LONG dwStyle)
70 {
71 return SHSetWindowBits(hWnd, GWL_STYLE, dwStyleMask, dwStyle);
72 }
73
74 static inline
75 LONG
76 SetWindowExStyle(IN HWND hWnd,
77 IN LONG dwStyleMask,
78 IN LONG dwStyle)
79 {
80 return SHSetWindowBits(hWnd, GWL_EXSTYLE, dwStyleMask, dwStyle);
81 }
82
83 HMENU
84 LoadPopupMenu(IN HINSTANCE hInstance,
85 IN LPCWSTR lpMenuName);
86
87 HMENU
88 FindSubMenu(IN HMENU hMenu,
89 IN UINT uItem,
90 IN BOOL fByPosition);
91
92 BOOL
93 GetCurrentLoggedOnUserName(OUT LPWSTR szBuffer,
94 IN DWORD dwBufferSize);
95
96 BOOL
97 FormatMenuString(IN HMENU hMenu,
98 IN UINT uPosition,
99 IN UINT uFlags,
100 ...);
101
102 BOOL
103 GetExplorerRegValueSet(IN HKEY hKey,
104 IN LPCWSTR lpSubKey,
105 IN LPCWSTR lpValue);
106
107 /*
108 * rshell.c
109 */
110
111 VOID InitRSHELL(VOID);
112 HRESULT WINAPI _CStartMenu_Constructor(REFIID riid, void **ppv);
113 HANDLE WINAPI _SHCreateDesktop(IShellDesktopTray *ShellDesk);
114 BOOL WINAPI _SHDesktopMessageLoop(HANDLE hDesktop);
115 DWORD WINAPI _WinList_Init(void);
116 void WINAPI _ShellDDEInit(BOOL bInit);
117 HRESULT WINAPI _CBandSiteMenu_CreateInstance(REFIID riid, void **ppv);
118 HRESULT WINAPI _CBandSite_CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, void **ppv);
119
120 /*
121 * traywnd.c
122 */
123
124 #define TWM_OPENSTARTMENU (WM_USER + 260)
125
126 extern const GUID IID_IShellDesktopTray;
127
128 #define INTERFACE ITrayWindow
129 DECLARE_INTERFACE_(ITrayWindow, IUnknown)
130 {
131 /*** IUnknown methods ***/
132 STDMETHOD_(HRESULT, QueryInterface) (THIS_ REFIID riid, void** ppvObject) PURE;
133 STDMETHOD_(ULONG, AddRef) (THIS) PURE;
134 STDMETHOD_(ULONG, Release) (THIS) PURE;
135 /*** ITrayWindow methods ***/
136 STDMETHOD_(HRESULT, Open) (THIS) PURE;
137 STDMETHOD_(HRESULT, Close) (THIS) PURE;
138 STDMETHOD_(HWND, GetHWND) (THIS) PURE;
139 STDMETHOD_(BOOL, IsSpecialHWND) (THIS_ HWND hWnd) PURE;
140 STDMETHOD_(BOOL, IsHorizontal) (THIS) PURE;
141 STDMETHOD_(HWND, DisplayProperties) (THIS) PURE;
142 STDMETHOD_(BOOL, ExecContextMenuCmd) (THIS_ UINT uiCmd) PURE;
143 STDMETHOD_(BOOL, Lock) (THIS_ BOOL bLock) PURE;
144 };
145 #undef INTERFACE
146
147 #if defined(COBJMACROS)
148 /*** IUnknown methods ***/
149 #define ITrayWindow_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
150 #define ITrayWindow_AddRef(p) (p)->lpVtbl->AddRef(p)
151 #define ITrayWindow_Release(p) (p)->lpVtbl->Release(p)
152 /*** ITrayWindow methods ***/
153 #define ITrayWindow_Open(p) (p)->lpVtbl->Open(p)
154 #define ITrayWindow_Close(p) (p)->lpVtbl->Close(p)
155 #define ITrayWindow_GetHWND(p) (p)->lpVtbl->GetHWND(p)
156 #define ITrayWindow_IsSpecialHWND(p,a) (p)->lpVtbl->IsSpecialHWND(p,a)
157 #define ITrayWindow_IsHorizontal(p) (p)->lpVtbl->IsHorizontal(p)
158 #define ITrayWindow_DisplayProperties(p) (p)->lpVtbl->DisplayProperties(p)
159 #define ITrayWindow_ExecContextMenuCmd(p,a) (p)->lpVtbl->ExecContextMenuCmd(p,a)
160 #define ITrayWindow_Lock(p,a) (p)->lpVtbl->Lock(p,a)
161 #endif
162
163 BOOL
164 RegisterTrayWindowClass(VOID);
165
166 VOID
167 UnregisterTrayWindowClass(VOID);
168
169 HRESULT CreateTrayWindow(ITrayWindow ** ppTray);
170
171 VOID
172 TrayProcessMessages(IN OUT ITrayWindow *Tray);
173
174 VOID
175 TrayMessageLoop(IN OUT ITrayWindow *Tray);
176
177 /*
178 * settings.c
179 */
180
181 /* Structure to hold non-default options*/
182 typedef struct _TASKBAR_SETTINGS
183 {
184 BOOL bLock;
185 BOOL bAutoHide;
186 BOOL bAlwaysOnTop;
187 BOOL bGroupButtons;
188 BOOL bShowQuickLaunch;
189 BOOL bShowClock;
190 BOOL bShowSeconds;
191 BOOL bHideInactiveIcons;
192 } TASKBAR_SETTINGS, *PTASKBAR_SETTINGS;
193
194 extern TASKBAR_SETTINGS TaskBarSettings;
195
196 VOID
197 LoadTaskBarSettings(VOID);
198
199 VOID
200 SaveTaskBarSettings(VOID);
201
202 BOOL
203 LoadSettingDword(IN LPCWSTR pszKeyName,
204 IN LPCWSTR pszValueName,
205 OUT DWORD &dwValue);
206 BOOL
207 SaveSettingDword(IN LPCWSTR pszKeyName,
208 IN LPCWSTR pszValueName,
209 IN DWORD dwValue);
210
211 /*
212 * shellservice.cpp
213 */
214 HRESULT InitShellServices(HDPA * phdpa);
215 HRESULT ShutdownShellServices(HDPA hdpa);
216
217 /*
218 * startup.cpp
219 */
220
221 int
222 ProcessStartupItems(VOID);
223
224 /*
225 * trayprop.h
226 */
227
228 VOID
229 DisplayTrayProperties(IN HWND hwndOwner);
230
231 /*
232 * desktop.cpp
233 */
234 HANDLE
235 DesktopCreateWindow(IN OUT ITrayWindow *Tray);
236
237 VOID
238 DesktopDestroyShellWindow(IN HANDLE hDesktop);
239
240
241 /*
242 * notifyiconscust.cpp
243 */
244 VOID
245 ShowCustomizeNotifyIcons(HINSTANCE, HWND);
246
247 /*
248 * taskband.cpp
249 */
250
251 extern const GUID CLSID_ITaskBand; /* Internal Task Band CLSID */
252 HRESULT CTaskBand_CreateInstance(IN ITrayWindow *Tray, HWND hWndStartButton, REFIID riid, void **ppv);
253
254 /*
255 * tbsite.cpp
256 */
257
258 #define INTERFACE ITrayBandSite
259 DECLARE_INTERFACE_(ITrayBandSite, IUnknown)
260 {
261 /*** IUnknown methods ***/
262 STDMETHOD_(HRESULT, QueryInterface) (THIS_ REFIID riid, void** ppvObject) PURE;
263 STDMETHOD_(ULONG, AddRef) (THIS) PURE;
264 STDMETHOD_(ULONG, Release) (THIS) PURE;
265 /*** IBandSiteStreamCallback ***/
266 STDMETHOD_(HRESULT, OnLoad)(THIS_ IStream *pStm, REFIID riid, PVOID *pvObj) PURE;
267 STDMETHOD_(HRESULT, OnSave)(THIS_ IUnknown *pUnk, IStream *pStm) PURE;
268 /*** ITrayBandSite methods ***/
269 STDMETHOD_(HRESULT, IsTaskBand) (THIS_ IUnknown *punk) PURE;
270 STDMETHOD_(HRESULT, ProcessMessage) (THIS_ HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *plResult) PURE;
271 STDMETHOD_(HRESULT, AddContextMenus) (THIS_ HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags, IContextMenu **ppcm) PURE;
272 STDMETHOD_(HRESULT, Lock) (THIS_ BOOL bLock) PURE;
273 };
274 #undef INTERFACE
275
276 #if defined(COBJMACROS)
277 /*** IUnknown methods ***/
278 #define ITrayBandSite_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
279 #define ITrayBandSite_AddRef(p) (p)->lpVtbl->AddRef(p)
280 #define ITrayBandSite_Release(p) (p)->lpVtbl->Release(p)
281 /*** IBandSiteStreamCallback methods ***/
282 #define ITrayBandSite_OnLoad(p,a,b,c) (p)->lpVtbl->OnLoad(p,a,b,c)
283 #define ITrayBandSite_OnSave(p,a,b) (p)->lpVtbl->OnSave(p,a,b)
284 /*** ITrayBandSite methods ***/
285 #define ITrayBandSite_IsTaskBand(p,a) (p)->lpVtbl->IsTaskBand(p,a)
286 #define ITrayBandSite_ProcessMessage(p,a,b,c,d,e) (p)->lpVtbl->ProcessMessage(p,a,b,c,d,e)
287 #define ITrayBandSite_AddContextMenus(p,a,b,c,d,e,f) (p)->lpVtbl->AddContextMenus(p,a,b,c,d,e,f)
288 #define ITrayBandSite_Lock(p,a) (p)->lpVtbl->Lock(p,a)
289 #endif
290
291 HRESULT CTrayBandSite_CreateInstance(IN ITrayWindow *tray, IN IDeskBand* pTaskBand, OUT ITrayBandSite** pBandSite);
292
293 /*
294 * startmnu.cpp
295 */
296
297 HRESULT StartMenuBtnCtxMenuCreator(ITrayWindow * TrayWnd, IN HWND hWndOwner, IContextMenu ** ppCtxMenu);
298
299 IMenuPopup*
300 CreateStartMenu(IN ITrayWindow *Tray,
301 OUT IMenuBand **ppMenuBand,
302 IN HBITMAP hbmBanner OPTIONAL,
303 IN BOOL bSmallIcons);
304
305 /*
306 * startmnucust.cpp
307 */
308 VOID
309 ShowCustomizeClassic(HINSTANCE, HWND);
310
311 /*
312 * startmnusite.cpp
313 */
314
315 HRESULT
316 CreateStartMenuSite(IN OUT ITrayWindow *Tray, const IID & riid, PVOID * ppv);
317
318 /*
319 * trayntfy.c
320 */
321
322 /* TrayClockWnd */
323 #define TCWM_GETMINIMUMSIZE (WM_USER + 0x100)
324 #define TCWM_UPDATETIME (WM_USER + 0x101)
325
326 /* TrayNotifyWnd */
327 #define TNWM_GETMINIMUMSIZE (WM_USER + 0x100)
328 #define TNWM_UPDATETIME (WM_USER + 0x101)
329 #define TNWM_SHOWCLOCK (WM_USER + 0x102)
330 #define TNWM_SHOWTRAY (WM_USER + 0x103)
331 #define TNWM_CHANGETRAYPOS (WM_USER + 0x104)
332
333 #define NTNWM_REALIGN (0x1)
334
335 class CTrayNotifyWnd;
336
337 BOOL
338 RegisterTrayNotifyWndClass(VOID);
339
340 VOID
341 UnregisterTrayNotifyWndClass(VOID);
342
343 HWND
344 CreateTrayNotifyWnd(IN OUT ITrayWindow *TrayWindow, IN BOOL bHideClock, CTrayNotifyWnd** ppTrayNotify);
345
346 BOOL
347 TrayNotify_NotifyIconCmd(CTrayNotifyWnd* pTrayNotify, IN WPARAM wParam, IN LPARAM lParam);
348
349 BOOL
350 TrayNotify_GetClockRect(CTrayNotifyWnd* pTrayNotify, OUT PRECT rcClock);
351
352 /*
353 * taskswnd.c
354 */
355
356 #define TSWM_ENABLEGROUPING (WM_USER + 1)
357 #define TSWM_UPDATETASKBARPOS (WM_USER + 2)
358
359 BOOL
360 RegisterTaskSwitchWndClass(VOID);
361
362 VOID
363 UnregisterTaskSwitchWndClass(VOID);
364
365 HWND
366 CreateTaskSwitchWnd(IN HWND hWndParent,
367 IN OUT ITrayWindow *Tray);
368
369 HRESULT
370 Tray_OnStartMenuDismissed(ITrayWindow* Tray);
371
372 HRESULT
373 IsSameObject(IN IUnknown *punk1, IN IUnknown *punk2);
374
375 #endif /* _EXPLORER_PRECOMP__H_ */