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