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