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