xref: /reactos/base/shell/explorer/precomp.h (revision 70d7009a)
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 #define OEMRESOURCE
21 
22 #include <windef.h>
23 #include <winbase.h>
24 #include <winreg.h>
25 #include <wingdi.h>
26 #include <winnls.h>
27 #include <wincon.h>
28 #include <atlbase.h>
29 #include <atlcom.h>
30 #include <atlwin.h>
31 #include <atlstr.h>
32 #include <atlcoll.h>
33 #include <atlsimpcoll.h>
34 #include <shellapi.h>
35 #include <shlobj.h>
36 #include <shlwapi.h>
37 #include <uxtheme.h>
38 #include <process.h>
39 #include <strsafe.h>
40 
41 #include <undocuser.h>
42 #include <shlwapi_undoc.h>
43 #include <shlobj_undoc.h>
44 #include <shlguid_undoc.h>
45 #include <undocshell.h>
46 
47 #include <ui/rosctrls.h>
48 #include <ui/rosdlgs.h>
49 #include <shellutils.h>
50 
51 #include "tmschema.h"
52 #include "resource.h"
53 
54 #include <wine/debug.h>
55 
56 WINE_DEFAULT_DEBUG_CHANNEL(explorernew);
57 
58 #define ASSERT(cond) \
59     do if (!(cond)) { \
60         Win32DbgPrint(__FILE__, __LINE__, "ASSERTION %s FAILED!\n", #cond); \
61         } while (0)
62 
63 extern HINSTANCE hExplorerInstance;
64 extern HANDLE hProcessHeap;
65 extern HKEY hkExplorer;
66 extern BOOL bExplorerIsShell;
67 
68 /*
69  * explorer.c
70  */
71 
72 static inline
73 LONG
SetWindowStyle(IN HWND hWnd,IN LONG dwStyleMask,IN LONG dwStyle)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
SetWindowExStyle(IN HWND hWnd,IN LONG dwStyleMask,IN LONG dwStyle)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 GetRegValue(IN LPCWSTR pszSubKey, IN LPCWSTR pszValueName, IN BOOL bDefaultValue);
110 BOOL SetRegDword(IN LPCWSTR pszSubKey, IN LPCWSTR pszValueName, IN DWORD dwValue);
111 BOOL GetAdvancedBool(IN LPCWSTR pszValueName, IN BOOL bDefaultValue);
112 BOOL SetAdvancedDword(IN LPCWSTR pszValueName, IN DWORD dwValue);
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_GETTASKSWITCH (WM_USER + 236)
132 #define TWM_OPENSTARTMENU (WM_USER + 260)
133 #define TWM_SETTINGSCHANGED (WM_USER + 300)
134 #define TWM_PULSE (WM_USER + 400)
135 
136 extern const GUID IID_IShellDesktopTray;
137 
138 #define INTERFACE ITrayWindow
DECLARE_INTERFACE_(ITrayWindow,IUnknown)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     STDMETHOD_(BOOL, IsTaskWnd) (THIS_ HWND hWnd) 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 #define ITrayWindow_IsTaskWnd(p,a)          (p)->lpVtbl->IsTaskWnd(p,a)
173 #endif
174 
175 HRESULT CreateTrayWindow(ITrayWindow ** ppTray);
176 
177 VOID
178 TrayProcessMessages(IN OUT ITrayWindow *Tray);
179 
180 VOID
181 TrayMessageLoop(IN OUT ITrayWindow *Tray);
182 
183 /*
184  * settings.c
185  */
186 
187 enum TrayIconsMode
188 {
189     TIM_Default,
190     TIM_NeverCompact,
191     TIM_AlwaysCompact,
192     TIM_Max = TIM_AlwaysCompact
193 };
194 
195 typedef struct _TW_STUCKRECTS2
196 {
197     DWORD cbSize;
198     LONG Unknown;
199     union
200     {
201         DWORD dwFlags;
202         struct
203         {
204             DWORD AutoHide : 1;
205             DWORD AlwaysOnTop : 1;
206             DWORD SmSmallIcons : 1; // Start menu Small Icons
207             DWORD HideClock : 1;
208         };
209     };
210     DWORD Position;
211     SIZE Size;
212     RECT Rect;
213 } TW_STRUCKRECTS2, *PTW_STUCKRECTS2;
214 
215 struct TaskbarSettings
216 {
217     BOOL bLock;
218     BOOL bGroupButtons;
219     BOOL bShowSeconds;
220     BOOL bPreferDate;
221     BOOL bHideInactiveIcons;
222     BOOL bSmallIcons;
223     TrayIconsMode eCompactTrayIcons;
224     BOOL bShowDesktopButton;
225     TW_STRUCKRECTS2 sr;
226 
227     BOOL Load();
228     BOOL Save();
UseCompactTrayIconsTaskbarSettings229     inline BOOL UseCompactTrayIcons()
230     {
231         switch (eCompactTrayIcons)
232         {
233             case TIM_NeverCompact:
234                 return FALSE;
235             case TIM_AlwaysCompact:
236                 return TRUE;
237             default:
238                 return bSmallIcons;
239         }
240     }
241 };
242 
243 extern TaskbarSettings g_TaskbarSettings;
244 
245 /*
246  * shellservice.cpp
247  */
248 HRESULT InitShellServices(HDPA * phdpa);
249 HRESULT ShutdownShellServices(HDPA hdpa);
250 
251 /*
252  * startup.cpp
253  */
254 
255 VOID ReleaseStartupMutex();
256 VOID ProcessRunOnceItems();
257 BOOL DoStartStartupItems(ITrayWindow *Tray);
258 INT ProcessStartupItems(BOOL bRunOnce);
ProcessStartupItems()259 static inline INT ProcessStartupItems() { return ProcessStartupItems(FALSE); }
DoFinishStartupItems()260 static inline VOID DoFinishStartupItems() { ReleaseStartupMutex(); }
261 
262 /*
263  * trayprop.h
264  */
265 
266 VOID
267 DisplayTrayProperties(IN HWND hwndOwner, IN HWND hwndTaskbar);
268 
269 /*
270  * desktop.cpp
271  */
272 HANDLE
273 DesktopCreateWindow(IN OUT ITrayWindow *Tray);
274 
275 VOID
276 DesktopDestroyShellWindow(IN HANDLE hDesktop);
277 
278 
279 /*
280  * notifyiconscust.cpp
281  */
282 VOID
283 ShowCustomizeNotifyIcons(HINSTANCE, HWND);
284 
285 /*
286  * taskband.cpp
287  */
288 
289 extern const GUID CLSID_ITaskBand;  /* Internal Task Band CLSID */
290 HRESULT CTaskBand_CreateInstance(IN ITrayWindow *Tray, HWND hWndStartButton, REFIID riid, void **ppv);
291 
292 /*
293  * tbsite.cpp
294  */
295 
296 #define INTERFACE ITrayBandSite
DECLARE_INTERFACE_(ITrayBandSite,IUnknown)297 DECLARE_INTERFACE_(ITrayBandSite, IUnknown)
298 {
299     /*** IUnknown methods ***/
300     STDMETHOD_(HRESULT, QueryInterface) (THIS_ REFIID riid, void** ppvObject) PURE;
301     STDMETHOD_(ULONG, AddRef) (THIS) PURE;
302     STDMETHOD_(ULONG, Release) (THIS) PURE;
303     /*** IBandSiteStreamCallback ***/
304     STDMETHOD_(HRESULT, OnLoad)(THIS_ IStream *pStm, REFIID riid, PVOID *pvObj) PURE;
305     STDMETHOD_(HRESULT, OnSave)(THIS_ IUnknown *pUnk, IStream *pStm) PURE;
306     /*** ITrayBandSite methods ***/
307     STDMETHOD_(HRESULT, IsTaskBand) (THIS_ IUnknown *punk) PURE;
308     STDMETHOD_(HRESULT, ProcessMessage) (THIS_ HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *plResult) PURE;
309     STDMETHOD_(HRESULT, AddContextMenus) (THIS_ HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags, IContextMenu **ppcm) PURE;
310     STDMETHOD_(HRESULT, Lock) (THIS_ BOOL bLock) PURE;
311 };
312 #undef INTERFACE
313 
314 #if defined(COBJMACROS)
315 /*** IUnknown methods ***/
316 #define ITrayBandSite_QueryInterface(p,a,b)             (p)->lpVtbl->QueryInterface(p,a,b)
317 #define ITrayBandSite_AddRef(p)                         (p)->lpVtbl->AddRef(p)
318 #define ITrayBandSite_Release(p)                        (p)->lpVtbl->Release(p)
319 /*** IBandSiteStreamCallback methods ***/
320 #define ITrayBandSite_OnLoad(p,a,b,c)                   (p)->lpVtbl->OnLoad(p,a,b,c)
321 #define ITrayBandSite_OnSave(p,a,b)                     (p)->lpVtbl->OnSave(p,a,b)
322 /*** ITrayBandSite methods ***/
323 #define ITrayBandSite_IsTaskBand(p,a)                   (p)->lpVtbl->IsTaskBand(p,a)
324 #define ITrayBandSite_ProcessMessage(p,a,b,c,d,e)       (p)->lpVtbl->ProcessMessage(p,a,b,c,d,e)
325 #define ITrayBandSite_AddContextMenus(p,a,b,c,d,e,f)    (p)->lpVtbl->AddContextMenus(p,a,b,c,d,e,f)
326 #define ITrayBandSite_Lock(p,a)                         (p)->lpVtbl->Lock(p,a)
327 #endif
328 
329 HRESULT CTrayBandSite_CreateInstance(IN ITrayWindow *tray, IN IDeskBand* pTaskBand, OUT ITrayBandSite** pBandSite);
330 
331 /*
332  * startctxmnu.cpp
333  */
334 HRESULT CStartMenuBtnCtxMenu_CreateInstance(ITrayWindow * TrayWnd, IN HWND hWndOwner, IContextMenu ** ppCtxMenu);
335 
336 /*
337  * startmnu.cpp
338  */
339 IMenuPopup*
340 CreateStartMenu(IN ITrayWindow *Tray,
341                 OUT IMenuBand **ppMenuBand,
342                 IN HBITMAP hbmBanner OPTIONAL,
343                 IN BOOL bSmallIcons);
344 HRESULT
345 UpdateStartMenu(IN OUT IMenuPopup *pMenuPopup,
346                 IN HBITMAP hbmBanner  OPTIONAL,
347                 IN BOOL bSmallIcons,
348                 IN BOOL bRefresh);
349 
350 /*
351  * startmnucust.cpp
352  */
353 VOID
354 ShowCustomizeClassic(HINSTANCE, HWND);
355 
356 /*
357 * startmnusite.cpp
358 */
359 HRESULT
360 CStartMenuSite_CreateInstance(IN OUT ITrayWindow *Tray, const IID & riid, PVOID * ppv);
361 
362 /*
363  * trayntfy.c
364  */
365 
366 /* TrayClockWnd */
367 HRESULT CTrayClockWnd_CreateInstance(HWND hwndParent, REFIID riid, void **ppv);
368 
369 /* TrayNotifyWnd */
370 #define TNWM_GETMINIMUMSIZE (WM_USER + 0x100)
371 #define TNWM_CHANGETRAYPOS  (WM_USER + 0x104)
372 #define TNWM_GETSHOWDESKTOPBUTTON (WM_USER + 0x7601)
373 
374 #define NTNWM_REALIGN   (0x1)
375 
376 HRESULT CTrayNotifyWnd_CreateInstance(HWND hwndParent, REFIID riid, void **ppv);
377 
378 /* SysPagerWnd */
379 HRESULT CSysPagerWnd_CreateInstance(HWND hwndParent, REFIID riid, void **ppv);
380 
381 #include "traydeskbtn.h"
382 
383 /*
384  * taskswnd.c
385  */
386 
387 #define TSWM_UPDATETASKBARPOS   (WM_USER + 2)
388 
389 HRESULT CTaskSwitchWnd_CreateInstance(IN HWND hWndParent, IN OUT ITrayWindow *Tray, REFIID riid, void **ppv);
390 
391 HRESULT
392 Tray_OnStartMenuDismissed(ITrayWindow* Tray);
393 
394 HRESULT
395 IsSameObject(IN IUnknown *punk1, IN IUnknown *punk2);
396 
397 #endif /* _EXPLORER_PRECOMP__H_ */
398