[EXPLORER] start reworking some code for loading/saving settings implementation CORE...
[reactos.git] / reactos / base / shell / explorer / precomp.h
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 <shellapi.h>
31 #include <shlobj.h>
32 #include <shlwapi.h>
33 #include <uxtheme.h>
34 #include <strsafe.h>
35
36 #include <undocuser.h>
37 #include <shlwapi_undoc.h>
38 #include <shlobj_undoc.h>
39 #include <shlguid_undoc.h>
40 #include <undocshell.h>
41
42 #include <rosctrls.h>
43 #include <shellutils.h>
44
45 #include "tmschema.h"
46 #include "resource.h"
47
48 #include <wine/debug.h>
49
50 WINE_DEFAULT_DEBUG_CHANNEL(explorernew);
51
52 #define ASSERT(cond) \
53 do if (!(cond)) { \
54 Win32DbgPrint(__FILE__, __LINE__, "ASSERTION %s FAILED!\n", #cond); \
55 } while (0)
56
57 extern HINSTANCE hExplorerInstance;
58 extern HANDLE hProcessHeap;
59 extern HKEY hkExplorer;
60
61 /*
62 * explorer.c
63 */
64
65 static inline
66 LONG
67 SetWindowStyle(IN HWND hWnd,
68 IN LONG dwStyleMask,
69 IN LONG dwStyle)
70 {
71 return SHSetWindowBits(hWnd, GWL_STYLE, dwStyleMask, dwStyle);
72 }
73
74 static inline
75 LONG
76 SetWindowExStyle(IN HWND hWnd,
77 IN LONG dwStyleMask,
78 IN LONG dwStyle)
79 {
80 return SHSetWindowBits(hWnd, GWL_EXSTYLE, dwStyleMask, dwStyle);
81 }
82
83 HMENU
84 LoadPopupMenu(IN HINSTANCE hInstance,
85 IN LPCWSTR lpMenuName);
86
87 HMENU
88 FindSubMenu(IN HMENU hMenu,
89 IN UINT uItem,
90 IN BOOL fByPosition);
91
92 BOOL
93 GetCurrentLoggedOnUserName(OUT LPWSTR szBuffer,
94 IN DWORD dwBufferSize);
95
96 BOOL
97 FormatMenuString(IN HMENU hMenu,
98 IN UINT uPosition,
99 IN UINT uFlags,
100 ...);
101
102 BOOL
103 GetExplorerRegValueSet(IN HKEY hKey,
104 IN LPCWSTR lpSubKey,
105 IN LPCWSTR lpValue);
106
107 /*
108 * rshell.c
109 */
110
111 HRESULT WINAPI _CStartMenu_Constructor(REFIID riid, void **ppv);
112 HANDLE WINAPI _SHCreateDesktop(IShellDesktopTray *ShellDesk);
113 BOOL WINAPI _SHDesktopMessageLoop(HANDLE hDesktop);
114 DWORD WINAPI _WinList_Init(void);
115 void WINAPI _ShellDDEInit(BOOL bInit);
116
117 /*
118 * traywnd.c
119 */
120
121 #define TWM_OPENSTARTMENU (WM_USER + 260)
122
123 extern const GUID IID_IShellDesktopTray;
124
125 #define INTERFACE ITrayWindow
126 DECLARE_INTERFACE_(ITrayWindow, IUnknown)
127 {
128 /*** IUnknown methods ***/
129 STDMETHOD_(HRESULT, QueryInterface) (THIS_ REFIID riid, void** ppvObject) PURE;
130 STDMETHOD_(ULONG, AddRef) (THIS) PURE;
131 STDMETHOD_(ULONG, Release) (THIS) PURE;
132 /*** ITrayWindow methods ***/
133 STDMETHOD_(HRESULT, Open) (THIS) PURE;
134 STDMETHOD_(HRESULT, Close) (THIS) PURE;
135 STDMETHOD_(HWND, GetHWND) (THIS) PURE;
136 STDMETHOD_(BOOL, IsSpecialHWND) (THIS_ HWND hWnd) PURE;
137 STDMETHOD_(BOOL, IsHorizontal) (THIS) PURE;
138 STDMETHOD_(HWND, DisplayProperties) (THIS) PURE;
139 STDMETHOD_(BOOL, ExecContextMenuCmd) (THIS_ UINT uiCmd) PURE;
140 STDMETHOD_(BOOL, Lock) (THIS_ BOOL bLock) PURE;
141 };
142 #undef INTERFACE
143
144 #if defined(COBJMACROS)
145 /*** IUnknown methods ***/
146 #define ITrayWindow_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
147 #define ITrayWindow_AddRef(p) (p)->lpVtbl->AddRef(p)
148 #define ITrayWindow_Release(p) (p)->lpVtbl->Release(p)
149 /*** ITrayWindow methods ***/
150 #define ITrayWindow_Open(p) (p)->lpVtbl->Open(p)
151 #define ITrayWindow_Close(p) (p)->lpVtbl->Close(p)
152 #define ITrayWindow_GetHWND(p) (p)->lpVtbl->GetHWND(p)
153 #define ITrayWindow_IsSpecialHWND(p,a) (p)->lpVtbl->IsSpecialHWND(p,a)
154 #define ITrayWindow_IsHorizontal(p) (p)->lpVtbl->IsHorizontal(p)
155 #define ITrayWindow_DisplayProperties(p) (p)->lpVtbl->DisplayProperties(p)
156 #define ITrayWindow_ExecContextMenuCmd(p,a) (p)->lpVtbl->ExecContextMenuCmd(p,a)
157 #define ITrayWindow_Lock(p,a) (p)->lpVtbl->Lock(p,a)
158 #endif
159
160 BOOL
161 RegisterTrayWindowClass(VOID);
162
163 VOID
164 UnregisterTrayWindowClass(VOID);
165
166 HRESULT CreateTrayWindow(ITrayWindow ** ppTray);
167
168 VOID
169 TrayProcessMessages(IN OUT ITrayWindow *Tray);
170
171 VOID
172 TrayMessageLoop(IN OUT ITrayWindow *Tray);
173
174 /*
175 * settings.c
176 */
177
178 /* Structure to hold non-default options*/
179 typedef struct _TASKBAR_SETTINGS
180 {
181 BOOL bLock;
182 BOOL bAutoHide;
183 BOOL bAlwaysOnTop;
184 BOOL bGroupButtons;
185 BOOL bShowQuickLaunch;
186 BOOL bShowClock;
187 BOOL bShowSeconds;
188 BOOL bHideInactiveIcons;
189 } TASKBAR_SETTINGS, *PTASKBAR_SETTINGS;
190
191 extern TASKBAR_SETTINGS TaskBarSettings;
192
193 VOID
194 LoadTaskBarSettings(VOID);
195
196 VOID
197 SaveTaskBarSettings(VOID);
198
199 BOOL
200 SaveSettingDword(IN LPCWSTR pszKeyName,
201 IN LPCWSTR pszValueName,
202 IN DWORD dwValue);
203
204 /*
205 * shellservice.cpp
206 */
207 HRESULT InitShellServices(HDPA * phdpa);
208 HRESULT ShutdownShellServices(HDPA hdpa);
209
210 /*
211 * startup.cpp
212 */
213
214 int
215 ProcessStartupItems(VOID);
216
217 /*
218 * trayprop.h
219 */
220
221 VOID
222 DisplayTrayProperties(IN HWND hwndOwner);
223
224 /*
225 * desktop.cpp
226 */
227 HANDLE
228 DesktopCreateWindow(IN OUT ITrayWindow *Tray);
229
230 VOID
231 DesktopDestroyShellWindow(IN HANDLE hDesktop);
232
233
234 /*
235 * notifyiconscust.cpp
236 */
237 VOID
238 ShowCustomizeNotifyIcons(HINSTANCE, HWND);
239
240 /*
241 * taskband.cpp
242 */
243
244 extern const GUID CLSID_ITaskBand; /* Internal Task Band CLSID */
245 HRESULT CTaskBand_CreateInstance(IN ITrayWindow *Tray, HWND hWndStartButton, REFIID riid, void **ppv);
246
247 /*
248 * tbsite.cpp
249 */
250
251 #define INTERFACE ITrayBandSite
252 DECLARE_INTERFACE_(ITrayBandSite, IUnknown)
253 {
254 /*** IUnknown methods ***/
255 STDMETHOD_(HRESULT, QueryInterface) (THIS_ REFIID riid, void** ppvObject) PURE;
256 STDMETHOD_(ULONG, AddRef) (THIS) PURE;
257 STDMETHOD_(ULONG, Release) (THIS) PURE;
258 /*** IBandSiteStreamCallback ***/
259 STDMETHOD_(HRESULT, OnLoad)(THIS_ IStream *pStm, REFIID riid, PVOID *pvObj) PURE;
260 STDMETHOD_(HRESULT, OnSave)(THIS_ IUnknown *pUnk, IStream *pStm) PURE;
261 /*** ITrayBandSite methods ***/
262 STDMETHOD_(HRESULT, IsTaskBand) (THIS_ IUnknown *punk) PURE;
263 STDMETHOD_(HRESULT, ProcessMessage) (THIS_ HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *plResult) PURE;
264 STDMETHOD_(HRESULT, AddContextMenus) (THIS_ HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags, IContextMenu **ppcm) PURE;
265 STDMETHOD_(HRESULT, Lock) (THIS_ BOOL bLock) PURE;
266 };
267 #undef INTERFACE
268
269 #if defined(COBJMACROS)
270 /*** IUnknown methods ***/
271 #define ITrayBandSite_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
272 #define ITrayBandSite_AddRef(p) (p)->lpVtbl->AddRef(p)
273 #define ITrayBandSite_Release(p) (p)->lpVtbl->Release(p)
274 /*** IBandSiteStreamCallback methods ***/
275 #define ITrayBandSite_OnLoad(p,a,b,c) (p)->lpVtbl->OnLoad(p,a,b,c)
276 #define ITrayBandSite_OnSave(p,a,b) (p)->lpVtbl->OnSave(p,a,b)
277 /*** ITrayBandSite methods ***/
278 #define ITrayBandSite_IsTaskBand(p,a) (p)->lpVtbl->IsTaskBand(p,a)
279 #define ITrayBandSite_ProcessMessage(p,a,b,c,d,e) (p)->lpVtbl->ProcessMessage(p,a,b,c,d,e)
280 #define ITrayBandSite_AddContextMenus(p,a,b,c,d,e,f) (p)->lpVtbl->AddContextMenus(p,a,b,c,d,e,f)
281 #define ITrayBandSite_Lock(p,a) (p)->lpVtbl->Lock(p,a)
282 #endif
283
284 HRESULT CTrayBandSite_CreateInstance(IN ITrayWindow *tray, IN IDeskBand* pTaskBand, OUT ITrayBandSite** pBandSite);
285
286 /*
287 * startmnu.cpp
288 */
289
290 HRESULT StartMenuBtnCtxMenuCreator(ITrayWindow * TrayWnd, IN HWND hWndOwner, IContextMenu ** ppCtxMenu);
291
292 IMenuPopup*
293 CreateStartMenu(IN ITrayWindow *Tray,
294 OUT IMenuBand **ppMenuBand,
295 IN HBITMAP hbmBanner OPTIONAL,
296 IN BOOL bSmallIcons);
297
298 /*
299 * startmnucust.cpp
300 */
301 VOID
302 ShowCustomizeClassic(HINSTANCE, HWND);
303
304 /*
305 * startmnusite.cpp
306 */
307
308 HRESULT
309 CreateStartMenuSite(IN OUT ITrayWindow *Tray, const IID & riid, PVOID * ppv);
310
311 /*
312 * trayntfy.c
313 */
314
315 /* TrayClockWnd */
316 #define TCWM_GETMINIMUMSIZE (WM_USER + 0x100)
317 #define TCWM_UPDATETIME (WM_USER + 0x101)
318
319 /* TrayNotifyWnd */
320 #define TNWM_GETMINIMUMSIZE (WM_USER + 0x100)
321 #define TNWM_UPDATETIME (WM_USER + 0x101)
322 #define TNWM_SHOWCLOCK (WM_USER + 0x102)
323 #define TNWM_SHOWTRAY (WM_USER + 0x103)
324 #define TNWM_CHANGETRAYPOS (WM_USER + 0x104)
325
326 #define NTNWM_REALIGN (0x1)
327
328 class CTrayNotifyWnd;
329
330 BOOL
331 RegisterTrayNotifyWndClass(VOID);
332
333 VOID
334 UnregisterTrayNotifyWndClass(VOID);
335
336 HWND
337 CreateTrayNotifyWnd(IN OUT ITrayWindow *TrayWindow, IN BOOL bHideClock, CTrayNotifyWnd** ppTrayNotify);
338
339 BOOL
340 TrayNotify_NotifyIconCmd(CTrayNotifyWnd* pTrayNotify, IN WPARAM wParam, IN LPARAM lParam);
341
342 BOOL
343 TrayNotify_GetClockRect(CTrayNotifyWnd* pTrayNotify, OUT PRECT rcClock);
344
345 /*
346 * taskswnd.c
347 */
348
349 #define TSWM_ENABLEGROUPING (WM_USER + 1)
350 #define TSWM_UPDATETASKBARPOS (WM_USER + 2)
351
352 BOOL
353 RegisterTaskSwitchWndClass(VOID);
354
355 VOID
356 UnregisterTaskSwitchWndClass(VOID);
357
358 HWND
359 CreateTaskSwitchWnd(IN HWND hWndParent,
360 IN OUT ITrayWindow *Tray);
361
362 HRESULT
363 Tray_OnStartMenuDismissed(ITrayWindow* Tray);
364
365 HRESULT
366 IsSameObject(IN IUnknown *punk1, IN IUnknown *punk2);
367
368 #endif /* _EXPLORER_PRECOMP__H_ */