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