xref: /reactos/base/shell/explorer/precomp.h (revision 9393fc32)
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 /*
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 
134 extern const GUID IID_IShellDesktopTray;
135 
136 #define INTERFACE ITrayWindow
137 DECLARE_INTERFACE_(ITrayWindow, IUnknown)
138 {
139     /*** IUnknown methods ***/
140     STDMETHOD_(HRESULT, QueryInterface) (THIS_ REFIID riid, void** ppvObject) PURE;
141     STDMETHOD_(ULONG, AddRef) (THIS) PURE;
142     STDMETHOD_(ULONG, Release) (THIS) PURE;
143     /*** ITrayWindow methods ***/
144     STDMETHOD_(HRESULT, Open) (THIS) PURE;
145     STDMETHOD_(HRESULT, Close) (THIS) PURE;
146     STDMETHOD_(HWND, GetHWND) (THIS) PURE;
147     STDMETHOD_(BOOL, IsSpecialHWND) (THIS_ HWND hWnd) PURE;
148     STDMETHOD_(BOOL, IsHorizontal) (THIS) PURE;
149     STDMETHOD_(HWND, DisplayProperties) (THIS) PURE;
150     STDMETHOD_(BOOL, ExecContextMenuCmd) (THIS_ UINT uiCmd) PURE;
151     STDMETHOD_(BOOL, Lock) (THIS_ BOOL bLock) PURE;
152 };
153 #undef INTERFACE
154 
155 #if defined(COBJMACROS)
156 /*** IUnknown methods ***/
157 #define ITrayWindow_QueryInterface(p,a,b)   (p)->lpVtbl->QueryInterface(p,a,b)
158 #define ITrayWindow_AddRef(p)               (p)->lpVtbl->AddRef(p)
159 #define ITrayWindow_Release(p)              (p)->lpVtbl->Release(p)
160 /*** ITrayWindow methods ***/
161 #define ITrayWindow_Open(p)                 (p)->lpVtbl->Open(p)
162 #define ITrayWindow_Close(p)                (p)->lpVtbl->Close(p)
163 #define ITrayWindow_GetHWND(p)              (p)->lpVtbl->GetHWND(p)
164 #define ITrayWindow_IsSpecialHWND(p,a)      (p)->lpVtbl->IsSpecialHWND(p,a)
165 #define ITrayWindow_IsHorizontal(p)         (p)->lpVtbl->IsHorizontal(p)
166 #define ITrayWindow_DisplayProperties(p)    (p)->lpVtbl->DisplayProperties(p)
167 #define ITrayWindow_ExecContextMenuCmd(p,a) (p)->lpVtbl->ExecContextMenuCmd(p,a)
168 #define ITrayWindow_Lock(p,a)               (p)->lpVtbl->Lock(p,a)
169 #endif
170 
171 HRESULT CreateTrayWindow(ITrayWindow ** ppTray);
172 
173 VOID
174 TrayProcessMessages(IN OUT ITrayWindow *Tray);
175 
176 VOID
177 TrayMessageLoop(IN OUT ITrayWindow *Tray);
178 
179 /*
180  * settings.c
181  */
182 
183 typedef struct _TW_STUCKRECTS2
184 {
185     DWORD cbSize;
186     LONG Unknown;
187     union
188     {
189         DWORD dwFlags;
190         struct
191         {
192             DWORD AutoHide : 1;
193             DWORD AlwaysOnTop : 1;
194             DWORD SmallIcons : 1;
195             DWORD HideClock : 1;
196         };
197     };
198     DWORD Position;
199     SIZE Size;
200     RECT Rect;
201 } TW_STRUCKRECTS2, *PTW_STUCKRECTS2;
202 
203 struct TaskbarSettings
204 {
205     BOOL bLock;
206     BOOL bGroupButtons;
207     BOOL bShowSeconds;
208     BOOL bHideInactiveIcons;
209     TW_STRUCKRECTS2 sr;
210 
211     BOOL Load();
212     BOOL Save();
213 };
214 
215 extern TaskbarSettings g_TaskbarSettings;
216 
217 /*
218  * shellservice.cpp
219  */
220 HRESULT InitShellServices(HDPA * phdpa);
221 HRESULT ShutdownShellServices(HDPA hdpa);
222 
223 /*
224  * startup.cpp
225  */
226 
227 BOOL DoStartStartupItems(ITrayWindow *Tray);
228 INT ProcessStartupItems(VOID);
229 BOOL DoFinishStartupItems(VOID);
230 
231 /*
232  * trayprop.h
233  */
234 
235 VOID
236 DisplayTrayProperties(IN HWND hwndOwner, IN HWND hwndTaskbar);
237 
238 /*
239  * desktop.cpp
240  */
241 HANDLE
242 DesktopCreateWindow(IN OUT ITrayWindow *Tray);
243 
244 VOID
245 DesktopDestroyShellWindow(IN HANDLE hDesktop);
246 
247 
248 /*
249  * notifyiconscust.cpp
250  */
251 VOID
252 ShowCustomizeNotifyIcons(HINSTANCE, HWND);
253 
254 /*
255  * taskband.cpp
256  */
257 
258 extern const GUID CLSID_ITaskBand;  /* Internal Task Band CLSID */
259 HRESULT CTaskBand_CreateInstance(IN ITrayWindow *Tray, HWND hWndStartButton, REFIID riid, void **ppv);
260 
261 /*
262  * tbsite.cpp
263  */
264 
265 #define INTERFACE ITrayBandSite
266 DECLARE_INTERFACE_(ITrayBandSite, IUnknown)
267 {
268     /*** IUnknown methods ***/
269     STDMETHOD_(HRESULT, QueryInterface) (THIS_ REFIID riid, void** ppvObject) PURE;
270     STDMETHOD_(ULONG, AddRef) (THIS) PURE;
271     STDMETHOD_(ULONG, Release) (THIS) PURE;
272     /*** IBandSiteStreamCallback ***/
273     STDMETHOD_(HRESULT, OnLoad)(THIS_ IStream *pStm, REFIID riid, PVOID *pvObj) PURE;
274     STDMETHOD_(HRESULT, OnSave)(THIS_ IUnknown *pUnk, IStream *pStm) PURE;
275     /*** ITrayBandSite methods ***/
276     STDMETHOD_(HRESULT, IsTaskBand) (THIS_ IUnknown *punk) PURE;
277     STDMETHOD_(HRESULT, ProcessMessage) (THIS_ HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *plResult) PURE;
278     STDMETHOD_(HRESULT, AddContextMenus) (THIS_ HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags, IContextMenu **ppcm) PURE;
279     STDMETHOD_(HRESULT, Lock) (THIS_ BOOL bLock) PURE;
280 };
281 #undef INTERFACE
282 
283 #if defined(COBJMACROS)
284 /*** IUnknown methods ***/
285 #define ITrayBandSite_QueryInterface(p,a,b)             (p)->lpVtbl->QueryInterface(p,a,b)
286 #define ITrayBandSite_AddRef(p)                         (p)->lpVtbl->AddRef(p)
287 #define ITrayBandSite_Release(p)                        (p)->lpVtbl->Release(p)
288 /*** IBandSiteStreamCallback methods ***/
289 #define ITrayBandSite_OnLoad(p,a,b,c)                   (p)->lpVtbl->OnLoad(p,a,b,c)
290 #define ITrayBandSite_OnSave(p,a,b)                     (p)->lpVtbl->OnSave(p,a,b)
291 /*** ITrayBandSite methods ***/
292 #define ITrayBandSite_IsTaskBand(p,a)                   (p)->lpVtbl->IsTaskBand(p,a)
293 #define ITrayBandSite_ProcessMessage(p,a,b,c,d,e)       (p)->lpVtbl->ProcessMessage(p,a,b,c,d,e)
294 #define ITrayBandSite_AddContextMenus(p,a,b,c,d,e,f)    (p)->lpVtbl->AddContextMenus(p,a,b,c,d,e,f)
295 #define ITrayBandSite_Lock(p,a)                         (p)->lpVtbl->Lock(p,a)
296 #endif
297 
298 HRESULT CTrayBandSite_CreateInstance(IN ITrayWindow *tray, IN IDeskBand* pTaskBand, OUT ITrayBandSite** pBandSite);
299 
300 /*
301  * startmnu.cpp
302  */
303 
304 HRESULT CStartMenuBtnCtxMenu_CreateInstance(ITrayWindow * TrayWnd, IN HWND hWndOwner, IContextMenu ** ppCtxMenu);
305 
306 IMenuPopup*
307 CreateStartMenu(IN ITrayWindow *Tray,
308                 OUT IMenuBand **ppMenuBand,
309                 IN HBITMAP hbmBanner OPTIONAL,
310                 IN BOOL bSmallIcons);
311 
312 /*
313  * startmnucust.cpp
314  */
315 VOID
316 ShowCustomizeClassic(HINSTANCE, HWND);
317 
318 /*
319 * startmnusite.cpp
320 */
321 
322 HRESULT
323 CStartMenuSite_CreateInstance(IN OUT ITrayWindow *Tray, const IID & riid, PVOID * ppv);
324 
325 /*
326  * trayntfy.c
327  */
328 
329 /* TrayClockWnd */
330 HRESULT CTrayClockWnd_CreateInstance(HWND hwndParent, REFIID riid, void **ppv);
331 
332 /* TrayNotifyWnd */
333 #define TNWM_GETMINIMUMSIZE (WM_USER + 0x100)
334 #define TNWM_CHANGETRAYPOS  (WM_USER + 0x104)
335 
336 #define NTNWM_REALIGN   (0x1)
337 
338 HRESULT CTrayNotifyWnd_CreateInstance(HWND hwndParent, REFIID riid, void **ppv);
339 
340 /* SysPagerWnd */
341 HRESULT CSysPagerWnd_CreateInstance(HWND hwndParent, REFIID riid, void **ppv);
342 
343 /*
344  * taskswnd.c
345  */
346 
347 #define TSWM_UPDATETASKBARPOS   (WM_USER + 2)
348 
349 HRESULT CTaskSwitchWnd_CreateInstance(IN HWND hWndParent, IN OUT ITrayWindow *Tray, REFIID riid, void **ppv);
350 
351 HRESULT
352 Tray_OnStartMenuDismissed(ITrayWindow* Tray);
353 
354 HRESULT
355 IsSameObject(IN IUnknown *punk1, IN IUnknown *punk2);
356 
357 #endif /* _EXPLORER_PRECOMP__H_ */
358