xref: /reactos/base/shell/explorer/precomp.h (revision 10e7643c)
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 <ui/rosctrls.h>
47 #include <ui/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 /*
68  * explorer.c
69  */
70 
71 static inline
72 LONG
73 SetWindowStyle(IN HWND hWnd,
74                IN LONG dwStyleMask,
75                IN LONG dwStyle)
76 {
77     return SHSetWindowBits(hWnd, GWL_STYLE, dwStyleMask, dwStyle);
78 }
79 
80 static inline
81 LONG
82 SetWindowExStyle(IN HWND hWnd,
83                  IN LONG dwStyleMask,
84                  IN LONG dwStyle)
85 {
86     return SHSetWindowBits(hWnd, GWL_EXSTYLE, dwStyleMask, dwStyle);
87 }
88 
89 HMENU
90 LoadPopupMenu(IN HINSTANCE hInstance,
91               IN LPCWSTR lpMenuName);
92 
93 HMENU
94 FindSubMenu(IN HMENU hMenu,
95             IN UINT uItem,
96             IN BOOL fByPosition);
97 
98 BOOL
99 GetCurrentLoggedOnUserName(OUT LPWSTR szBuffer,
100                            IN DWORD dwBufferSize);
101 
102 BOOL
103 FormatMenuString(IN HMENU hMenu,
104                  IN UINT uPosition,
105                  IN UINT uFlags,
106                  ...);
107 
108 BOOL
109 GetExplorerRegValueSet(IN HKEY hKey,
110                        IN LPCWSTR lpSubKey,
111                        IN LPCWSTR lpValue);
112 
113 /*
114  *  rshell.c
115  */
116 
117 VOID InitRSHELL(VOID);
118 HRESULT WINAPI _CStartMenu_CreateInstance(REFIID riid, void **ppv);
119 HANDLE WINAPI _SHCreateDesktop(IShellDesktopTray *ShellDesk);
120 BOOL WINAPI _SHDesktopMessageLoop(HANDLE hDesktop);
121 DWORD WINAPI _WinList_Init(void);
122 void WINAPI _ShellDDEInit(BOOL bInit);
123 HRESULT WINAPI _CBandSiteMenu_CreateInstance(REFIID riid, void **ppv);
124 HRESULT WINAPI _CBandSite_CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, void **ppv);
125 
126 /*
127  * traywnd.c
128  */
129 
130 #define TWM_GETTASKSWITCH (WM_USER + 236)
131 #define TWM_OPENSTARTMENU (WM_USER + 260)
132 #define TWM_SETTINGSCHANGED (WM_USER + 300)
133 #define TWM_PULSE (WM_USER + 400)
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     STDMETHOD_(BOOL, IsTaskWnd) (THIS_ HWND hWnd) 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 #define ITrayWindow_IsTaskWnd(p,a)          (p)->lpVtbl->IsTaskWnd(p,a)
172 #endif
173 
174 HRESULT CreateTrayWindow(ITrayWindow ** ppTray);
175 
176 VOID
177 TrayProcessMessages(IN OUT ITrayWindow *Tray);
178 
179 VOID
180 TrayMessageLoop(IN OUT ITrayWindow *Tray);
181 
182 /*
183  * settings.c
184  */
185 
186 typedef struct _TW_STUCKRECTS2
187 {
188     DWORD cbSize;
189     LONG Unknown;
190     union
191     {
192         DWORD dwFlags;
193         struct
194         {
195             DWORD AutoHide : 1;
196             DWORD AlwaysOnTop : 1;
197             DWORD SmallIcons : 1;
198             DWORD HideClock : 1;
199         };
200     };
201     DWORD Position;
202     SIZE Size;
203     RECT Rect;
204 } TW_STRUCKRECTS2, *PTW_STUCKRECTS2;
205 
206 struct TaskbarSettings
207 {
208     BOOL bLock;
209     BOOL bGroupButtons;
210     BOOL bShowSeconds;
211     BOOL bPreferDate;
212     BOOL bHideInactiveIcons;
213     BOOL bSmallIcons;
214     BOOL bCompactTrayIcons;
215     BOOL bShowDesktopButton;
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 CStartMenuBtnCtxMenu_CreateInstance(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 CStartMenuSite_CreateInstance(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_ */
365