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