Doxygen

precomp.h
Go to the documentation of this file.
00001 #ifndef _EXPLORER_PRECOMP__H_
00002 #define _EXPLORER_PRECOMP__H_
00003 #define COBJMACROS
00004 
00005 #define WIN32_NO_STATUS
00006 #define _INC_WINDOWS
00007 #define COM_NO_WINDOWS_H
00008 #include <stdarg.h>
00009 #include <windef.h>
00010 #include <winbase.h>
00011 #include <winreg.h>
00012 #include <wingdi.h>
00013 #include <winnls.h>
00014 #include <winver.h>
00015 #include <wincon.h>
00016 #include <shellapi.h>
00017 #include <shlobj.h>
00018 #include <shlobj_undoc.h>
00019 #include <shlwapi.h>
00020 #include <shlguid_undoc.h>
00021 #include <tchar.h>
00022 #include <stdio.h>
00023 #include <uxtheme.h>
00024 
00025 #include "tmschema.h"
00026 #include "resource.h"
00027 #include "comcsup.h"
00028 //#include "todo.h"
00029 //#include "initguid.h"
00030 #include "undoc.h"
00031 
00032 /* dynamic imports due to lack of support in msvc linker libs */
00033 typedef INT (APIENTRY *REGSHELLHOOK)(HWND, DWORD);
00034 #ifdef UNICODE
00035 #define PROC_NAME_DRAWCAPTIONTEMP "DrawCaptionTempW"
00036 typedef BOOL (APIENTRY *DRAWCAPTEMP)(HWND, HDC, const RECT*, HFONT, HICON, LPCWSTR, UINT);
00037 #else
00038 #define PROC_NAME_DRAWCAPTIONTEMP "DrawCaptionTempA"
00039 typedef BOOL (APIENTRY *DRAWCAPTEMP)(HWND, HDC, const RECT*, HFONT, HICON, LPCSTR, UINT);
00040 #endif
00041 typedef HRESULT (APIENTRY *SHINVDEFCMD)(HWND, IShellFolder*, LPCITEMIDLIST);
00042 typedef void (APIENTRY *RUNFILEDLG)(HWND, HICON, LPCWSTR, LPCWSTR, LPCWSTR, UINT);
00043 typedef void (APIENTRY *EXITWINDLG)(HWND);
00044 typedef HRESULT (APIENTRY *SHWINHELP)(HWND, LPWSTR, UINT, DWORD);
00045 
00046 /* Constants for RunFileDlg */
00047 #define RFF_CALCDIRECTORY   0x04    /* Calculates the working directory from the file name. */
00048 
00049 static __inline ULONG
00050 Win32DbgPrint(const char *filename, int line, const char *lpFormat, ...)
00051 {
00052     char szMsg[512];
00053     char *szMsgStart;
00054     const char *fname;
00055     va_list vl;
00056     ULONG uRet;
00057 
00058     fname = strrchr(filename, '\\');
00059     if (fname == NULL)
00060     {
00061         fname = strrchr(filename, '/');
00062         if (fname != NULL)
00063             fname++;
00064     }
00065     else
00066         fname++;
00067 
00068     if (fname == NULL)
00069         fname = filename;
00070 
00071     szMsgStart = szMsg + sprintf(szMsg, "%s:%d: ", fname, line);
00072 
00073     va_start(vl, lpFormat);
00074     uRet = (ULONG)vsprintf(szMsgStart, lpFormat, vl);
00075     va_end(vl);
00076 
00077     OutputDebugStringA(szMsg);
00078 
00079     return uRet;
00080 }
00081 
00082 #define ASSERT(cond) \
00083     do if (!(cond)) { \
00084         Win32DbgPrint(__FILE__, __LINE__, "ASSERTION %s FAILED!\n", #cond); \
00085     } while (0)
00086 
00087 #define DbgPrint(fmt, ...) \
00088     Win32DbgPrint(__FILE__, __LINE__, fmt, ##__VA_ARGS__)
00089 
00090 extern HINSTANCE hExplorerInstance;
00091 extern HMODULE hUser32;
00092 extern HANDLE hProcessHeap;
00093 extern HKEY hkExplorer;
00094 extern DRAWCAPTEMP DrawCapTemp;
00095 
00096 /*
00097  * dragdrop.c
00098  */
00099 
00100 typedef struct _DROPTARGET_CALLBACKS
00101 {
00102     HRESULT (*OnDragEnter)(IN IDropTarget *pDropTarget,
00103                            IN PVOID Context,
00104                            IN const FORMATETC *Format,
00105                            IN DWORD grfKeyState,
00106                            IN POINTL pt,
00107                            IN OUT DWORD *pdwEffect);
00108     HRESULT (*OnDragOver)(IN IDropTarget *pDropTarget,
00109                           IN PVOID Context,
00110                           IN DWORD grfKeyState,
00111                           IN POINTL pt,
00112                           IN OUT DWORD *pdwEffect);
00113     HRESULT (*OnDragLeave)(IN IDropTarget *pDropTarget,
00114                            IN PVOID Context);
00115     HRESULT (*OnDrop)(IN IDropTarget *pDropTarget,
00116                       IN PVOID Context,
00117                       IN const FORMATETC *Format,
00118                       IN DWORD grfKeyState,
00119                       IN POINTL pt,
00120                       IN OUT DWORD *pdwEffect);
00121 } DROPTARGET_CALLBACKS, *PDROPTARGET_CALLBACKS;
00122 
00123 IDropTarget *
00124 CreateDropTarget(IN HWND hwndTarget,
00125                  IN DWORD nSupportedFormats,
00126                  IN const FORMATETC *Formats  OPTIONAL,
00127                  IN PVOID Context  OPTIONAL,
00128                  IN const DROPTARGET_CALLBACKS *Callbacks  OPTIONAL);
00129 
00130 /*
00131  * explorer.c
00132  */
00133 
00134 #define IDHK_RUN 1 /* Win+R */
00135 
00136 LONG
00137 SetWindowStyle(IN HWND hWnd,
00138                IN LONG dwStyleMask,
00139                IN LONG dwStyle);
00140 
00141 LONG
00142 SetWindowExStyle(IN HWND hWnd,
00143                  IN LONG dwStyleMask,
00144                  IN LONG dwStyle);
00145 
00146 HMENU
00147 LoadPopupMenu(IN HINSTANCE hInstance,
00148               IN LPCTSTR lpMenuName);
00149 
00150 HMENU
00151 FindSubMenu(IN HMENU hMenu,
00152             IN UINT uItem,
00153             IN BOOL fByPosition);
00154 
00155 BOOL
00156 GetCurrentLoggedOnUserName(OUT LPTSTR szBuffer,
00157                            IN DWORD dwBufferSize);
00158 
00159 BOOL
00160 FormatMenuString(IN HMENU hMenu,
00161                  IN UINT uPosition,
00162                  IN UINT uFlags,
00163                  ...);
00164 
00165 BOOL
00166 GetExplorerRegValueSet(IN HKEY hKey,
00167                        IN LPCTSTR lpSubKey,
00168                        IN LPCTSTR lpValue);
00169 
00170 /*
00171  * traywnd.c
00172  */
00173 
00174 #define TWM_OPENSTARTMENU (WM_USER + 260)
00175 
00176 typedef HMENU (*PCREATECTXMENU)(IN HWND hWndOwner,
00177                                 IN PVOID *ppcmContext,
00178                                 IN PVOID Context  OPTIONAL);
00179 typedef VOID (*PCTXMENUCOMMAND)(IN HWND hWndOwner,
00180                                 IN UINT uiCmdId,
00181                                 IN PVOID pcmContext  OPTIONAL,
00182                                 IN PVOID Context  OPTIONAL);
00183 
00184 typedef struct _TRAYWINDOW_CTXMENU
00185 {
00186     PCREATECTXMENU CreateCtxMenu;
00187     PCTXMENUCOMMAND CtxMenuCommand;
00188 } TRAYWINDOW_CTXMENU, *PTRAYWINDOW_CTXMENU;
00189 
00190 extern const GUID IID_IShellDesktopTray;
00191 
00192 #define INTERFACE ITrayWindow
00193 DECLARE_INTERFACE_(ITrayWindow,IUnknown)
00194 {
00195     /*** IUnknown methods ***/
00196     STDMETHOD_(HRESULT,QueryInterface) (THIS_ REFIID riid, void** ppvObject) PURE;
00197     STDMETHOD_(ULONG,AddRef) (THIS) PURE;
00198     STDMETHOD_(ULONG,Release) (THIS) PURE;
00199     /*** ITrayWindow methods ***/
00200     STDMETHOD_(HRESULT,Open) (THIS) PURE;
00201     STDMETHOD_(HRESULT,Close) (THIS) PURE;
00202     STDMETHOD_(HWND,GetHWND) (THIS) PURE;
00203     STDMETHOD_(BOOL,IsSpecialHWND) (THIS_ HWND hWnd) PURE;
00204     STDMETHOD_(BOOL,IsHorizontal) (THIS) PURE;
00205     STDMETHOD_(HFONT,GetCaptionFonts) (THIS_ HFONT *phBoldCaption) PURE;
00206     STDMETHOD_(HWND,DisplayProperties) (THIS) PURE;
00207     STDMETHOD_(BOOL,ExecContextMenuCmd) (THIS_ UINT uiCmd) PURE;
00208     STDMETHOD_(BOOL,Lock) (THIS_ BOOL bLock) PURE;
00209 };
00210 #undef INTERFACE
00211 
00212 #if defined(COBJMACROS)
00213 /*** IUnknown methods ***/
00214 #define ITrayWindow_QueryInterface(p,a,b)   (p)->lpVtbl->QueryInterface(p,a,b)
00215 #define ITrayWindow_AddRef(p)               (p)->lpVtbl->AddRef(p)
00216 #define ITrayWindow_Release(p)              (p)->lpVtbl->Release(p)
00217 /*** ITrayWindow methods ***/
00218 #define ITrayWindow_Open(p)                 (p)->lpVtbl->Open(p)
00219 #define ITrayWindow_Close(p)                (p)->lpVtbl->Close(p)
00220 #define ITrayWindow_GetHWND(p)              (p)->lpVtbl->GetHWND(p)
00221 #define ITrayWindow_IsSpecialHWND(p,a)      (p)->lpVtbl->IsSpecialHWND(p,a)
00222 #define ITrayWindow_IsHorizontal(p)         (p)->lpVtbl->IsHorizontal(p)
00223 #define ITrayWindow_GetCaptionFonts(p,a)    (p)->lpVtbl->GetCaptionFonts(p,a)
00224 #define ITrayWindow_DisplayProperties(p)    (p)->lpVtbl->DisplayProperties(p)
00225 #define ITrayWindow_ExecContextMenuCmd(p,a) (p)->lpVtbl->ExecContextMenuCmd(p,a)
00226 #define ITrayWindow_Lock(p,a)               (p)->lpVtbl->Lock(p,a)
00227 #endif
00228 
00229 BOOL
00230 RegisterTrayWindowClass(VOID);
00231 
00232 VOID
00233 UnregisterTrayWindowClass(VOID);
00234 
00235 ITrayWindow *
00236 CreateTrayWindow(VOID);
00237 
00238 VOID
00239 TrayProcessMessages(IN OUT ITrayWindow *Tray);
00240 
00241 VOID
00242 TrayMessageLoop(IN OUT ITrayWindow *Tray);
00243 
00244 /*
00245  * settings.c
00246  */
00247 
00248 /* Structure to hold non-default options*/
00249 typedef struct _ADVANCED_SETTINGS {
00250     BOOL bShowSeconds;
00251 } ADVANCED_SETTINGS, *PADVANCED_SETTINGS;
00252 
00253 extern ADVANCED_SETTINGS AdvancedSettings;
00254 extern const TCHAR szAdvancedSettingsKey[];
00255 
00256 VOID
00257 LoadAdvancedSettings(VOID);
00258 
00259 BOOL
00260 SaveSettingDword(IN PCTSTR pszKeyName,
00261                  IN PCTSTR pszValueName,
00262                  IN DWORD dwValue);
00263 
00264 /*
00265  * startup.c
00266  */
00267 
00268 int
00269 ProcessStartupItems(VOID);
00270 
00271 /*
00272  * trayprop.h
00273  */
00274 
00275 VOID
00276 DisplayTrayProperties(IN HWND hwndOwner);
00277 
00278 /*
00279  * desktop.c
00280  */
00281 HANDLE
00282 DesktopCreateWindow(IN OUT ITrayWindow *Tray);
00283 
00284 VOID
00285 DesktopDestroyShellWindow(IN HANDLE hDesktop);
00286 
00287 /*
00288  * taskband.c
00289  */
00290 
00291 /* Internal Task Band CLSID */
00292 extern const GUID CLSID_ITaskBand;
00293 
00294 #define INTERFACE ITaskBand
00295 DECLARE_INTERFACE_(ITaskBand,IUnknown)
00296 {
00297     /*** IUnknown methods ***/
00298     STDMETHOD_(HRESULT,QueryInterface) (THIS_ REFIID riid, void** ppvObject) PURE;
00299     STDMETHOD_(ULONG,AddRef) (THIS) PURE;
00300     STDMETHOD_(ULONG,Release) (THIS) PURE;
00301     /*** ITaskBand methods ***/
00302     STDMETHOD_(HRESULT,GetRebarBandID)(THIS_ DWORD *pdwBandID) PURE;
00303 };
00304 #undef INTERFACE
00305 
00306 #if defined(COBJMACROS)
00307 /*** IUnknown methods ***/
00308 #define ITaskBand_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b)
00309 #define ITaskBand_AddRef(p)             (p)->lpVtbl->AddRef(p)
00310 #define ITaskBand_Release(p)            (p)->lpVtbl->Release(p)
00311 /*** ITaskBand methods ***/
00312 #define ITaskBand_GetRebarBandID(p,a)   (p)->lpVtbl->GetRebarBandID(p,a)
00313 #endif
00314 
00315 ITaskBand *
00316 CreateTaskBand(IN OUT ITrayWindow *Tray);
00317 
00318 /*
00319  * tbsite.c
00320  */
00321 
00322 #define INTERFACE ITrayBandSite
00323 DECLARE_INTERFACE_(ITrayBandSite,IUnknown)
00324 {
00325     /*** IUnknown methods ***/
00326     STDMETHOD_(HRESULT,QueryInterface) (THIS_ REFIID riid, void** ppvObject) PURE;
00327     STDMETHOD_(ULONG,AddRef) (THIS) PURE;
00328     STDMETHOD_(ULONG,Release) (THIS) PURE;
00329     /*** IBandSiteStreamCallback ***/
00330     STDMETHOD_(HRESULT,OnLoad)(THIS_ IStream *pStm, REFIID riid, PVOID *pvObj) PURE;
00331     STDMETHOD_(HRESULT,OnSave)(THIS_ IUnknown *pUnk, IStream *pStm) PURE;
00332     /*** ITrayBandSite methods ***/
00333     STDMETHOD_(HRESULT,IsTaskBand) (THIS_ IUnknown *punk) PURE;
00334     STDMETHOD_(HRESULT,ProcessMessage) (THIS_ HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *plResult) PURE;
00335     STDMETHOD_(HRESULT,AddContextMenus) (THIS_ HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags, IContextMenu **ppcm) PURE;
00336     STDMETHOD_(HRESULT,Lock) (THIS_ BOOL bLock) PURE;
00337 };
00338 #undef INTERFACE
00339 
00340 #if defined(COBJMACROS)
00341 /*** IUnknown methods ***/
00342 #define ITrayBandSite_QueryInterface(p,a,b)             (p)->lpVtbl->QueryInterface(p,a,b)
00343 #define ITrayBandSite_AddRef(p)                         (p)->lpVtbl->AddRef(p)
00344 #define ITrayBandSite_Release(p)                        (p)->lpVtbl->Release(p)
00345 /*** IBandSiteStreamCallback methods ***/
00346 #define ITrayBandSite_OnLoad(p,a,b,c)                   (p)->lpVtbl->OnLoad(p,a,b,c)
00347 #define ITrayBandSite_OnSave(p,a,b)                     (p)->lpVtbl->OnSave(p,a,b)
00348 /*** ITrayBandSite methods ***/
00349 #define ITrayBandSite_IsTaskBand(p,a)                   (p)->lpVtbl->IsTaskBand(p,a)
00350 #define ITrayBandSite_ProcessMessage(p,a,b,c,d,e)       (p)->lpVtbl->ProcessMessage(p,a,b,c,d,e)
00351 #define ITrayBandSite_AddContextMenus(p,a,b,c,d,e,f)    (p)->lpVtbl->AddContextMenus(p,a,b,c,d,e,f)
00352 #define ITrayBandSite_Lock(p,a)                         (p)->lpVtbl->Lock(p,a)
00353 #endif
00354 
00355 ITrayBandSite *
00356 CreateTrayBandSite(IN OUT ITrayWindow *Tray,
00357                    OUT HWND *phWndRebar,
00358                    OUT HWND *phWndTaskSwitch);
00359 
00360 /*
00361  * startmnu.c
00362  */
00363 
00364 extern const TRAYWINDOW_CTXMENU StartMenuBtnCtxMenu;
00365 
00366 #define INTERFACE IStartMenuSite
00367 DECLARE_INTERFACE_(IStartMenuSite,IUnknown)
00368 {
00369     /*** IUnknown methods ***/
00370     STDMETHOD_(HRESULT,QueryInterface) (THIS_ REFIID riid, void** ppvObject) PURE;
00371     STDMETHOD_(ULONG,AddRef) (THIS) PURE;
00372     STDMETHOD_(ULONG,Release) (THIS) PURE;
00373     /*** IStartMenuSite ***/
00374 };
00375 #undef INTERFACE
00376 
00377 #if defined(COBJMACROS)
00378 /*** IUnknown methods ***/
00379 #define IStartMenuSite_QueryInterface(p,a,b)             (p)->lpVtbl->QueryInterface(p,a,b)
00380 #define IStartMenuSite_AddRef(p)                         (p)->lpVtbl->AddRef(p)
00381 #define IStartMenuSite_Release(p)                        (p)->lpVtbl->Release(p)
00382 /*** IStartMenuSite methods ***/
00383 #endif
00384 
00385 IMenuPopup*
00386 CreateStartMenu(IN ITrayWindow *Tray,
00387                 OUT IMenuBand **ppMenuBand,
00388                 IN HBITMAP hbmBanner  OPTIONAL,
00389                 IN BOOL bSmallIcons);
00390 
00391 HRESULT
00392 UpdateStartMenu(IN OUT IMenuPopup *pMenuPopup,
00393                 IN HBITMAP hbmBanner  OPTIONAL,
00394                 IN BOOL bSmallIcons);
00395 
00396 /*
00397  * trayntfy.c
00398  */
00399 
00400 /* TrayClockWnd */
00401 #define TCWM_GETMINIMUMSIZE (WM_USER + 0x100)
00402 #define TCWM_UPDATETIME     (WM_USER + 0x101)
00403 
00404 /* TrayNotifyWnd */
00405 #define TNWM_GETMINIMUMSIZE (WM_USER + 0x100)
00406 #define TNWM_UPDATETIME     (WM_USER + 0x101)
00407 #define TNWM_SHOWCLOCK      (WM_USER + 0x102)
00408 #define TNWM_SHOWTRAY       (WM_USER + 0x103)
00409 #define TNWM_CHANGETRAYPOS  (WM_USER + 0x104)
00410 
00411 #define NTNWM_REALIGN   (0x1)
00412 
00413 BOOL
00414 RegisterTrayNotifyWndClass(VOID);
00415 
00416 VOID
00417 UnregisterTrayNotifyWndClass(VOID);
00418 
00419 HWND
00420 CreateTrayNotifyWnd(IN OUT ITrayWindow *TrayWindow,
00421                     IN BOOL bHideClock);
00422 
00423 VOID
00424 TrayNotify_NotifyMsg(IN HWND hwnd,
00425                      IN WPARAM wParam,
00426                      IN LPARAM lParam);
00427 
00428 BOOL
00429 TrayNotify_GetClockRect(IN HWND hwnd,
00430                         OUT PRECT rcClock);
00431 
00432 /*
00433  * taskswnd.c
00434  */
00435 
00436 #define TSWM_ENABLEGROUPING     (WM_USER + 1)
00437 #define TSWM_UPDATETASKBARPOS   (WM_USER + 2)
00438 
00439 BOOL
00440 RegisterTaskSwitchWndClass(VOID);
00441 
00442 VOID
00443 UnregisterTaskSwitchWndClass(VOID);
00444 
00445 HWND
00446 CreateTaskSwitchWnd(IN HWND hWndParent,
00447                     IN OUT ITrayWindow *Tray);
00448 
00449 #endif /* _EXPLORER_PRECOMP__H_ */