Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

152 lines
7.1 KiB

  1. #ifndef _DBACK_H_
  2. #define _DBACK_H_
  3. #include <shimgdata.h>
  4. #include "theme.h"
  5. #include "dcomp.h"
  6. #include "colorctrl.h"
  7. #define SZ_ICONHEADER L"CLSID\\{"
  8. HRESULT GetActiveDesktop(IActiveDesktop ** ppActiveDesktop);
  9. HRESULT ReleaseActiveDesktop(IActiveDesktop ** ppActiveDesktop);
  10. EXTERN_C BOOL g_fDirtyAdvanced;
  11. EXTERN_C BOOL g_fLaunchGallery;
  12. typedef struct tagDESKICONDATA {
  13. BOOL fHideIcon; //To hide the icon on desktop?
  14. BOOL fDirty; //Has this entry been modified and we not yet saved.
  15. } DESKICONDATA;
  16. typedef struct tagDeskIconNonEnumData {
  17. ULONG rgfAttributes; // ShellFolder\Attributes are saved here.
  18. BOOL fNonEnumPolicySet; // Disable the control because of policy Set.
  19. } DESKICON_NONENUMDATA;
  20. class CBackPropSheetPage : public CObjectWithSite
  21. , public CObjectCLSID
  22. , public IBasePropPage
  23. , public IPropertyBag
  24. {
  25. public:
  26. // *** IUnknown ***
  27. virtual STDMETHODIMP QueryInterface(REFIID riid, LPVOID *ppvObj);
  28. virtual STDMETHODIMP_(ULONG) AddRef(void);
  29. virtual STDMETHODIMP_(ULONG) Release(void);
  30. // *** IBasePropPage ***
  31. virtual STDMETHODIMP GetAdvancedDialog(OUT IAdvancedDialog ** ppAdvDialog);
  32. virtual STDMETHODIMP OnApply(IN PROPPAGEONAPPLY oaAction);
  33. // *** IPropertyBag ***
  34. virtual STDMETHODIMP Read(IN LPCOLESTR pszPropName, IN VARIANT * pVar, IN IErrorLog *pErrorLog);
  35. virtual STDMETHODIMP Write(IN LPCOLESTR pszPropName, IN VARIANT *pVar);
  36. // *** IShellPropSheetExt ***
  37. virtual STDMETHODIMP AddPages(IN LPFNSVADDPROPSHEETPAGE pfnAddPage, IN LPARAM lParam);
  38. virtual STDMETHODIMP ReplacePage(IN EXPPS uPageID, IN LPFNSVADDPROPSHEETPAGE pfnReplaceWith, IN LPARAM lParam) {return E_NOTIMPL;}
  39. CBackPropSheetPage(void);
  40. virtual ~CBackPropSheetPage(void);
  41. protected:
  42. ICONDATA _IconData[NUM_ICONS];
  43. DESKICONDATA _aHideDesktopIcon[2][NUM_DESKICONS];
  44. BOOL _fHideDesktopIconDirty;
  45. DESKICON_NONENUMDATA _aDeskIconNonEnumData[NUM_DESKICONS];
  46. BOOL _fStateLoaded; // Have we loaded the state yet?
  47. BOOL _fOpenAdvOnInit; // Does the caller want us to open the Advanced dialog when we initialize?
  48. HWND _hwnd; // This is the hwnd of the property page.
  49. HWND _hwndLV;
  50. HWND _hwndWPStyle;
  51. BOOL _fAllowHtml;
  52. BOOL _fAllowAD;
  53. BOOL _fAllowChanges;
  54. BOOL _fPolicyForWallpaper; //Is there a policy for wallpaper?
  55. BOOL _fPolicyForStyle; //Is there a policy for Wallpaper style?
  56. BOOL _fForceAD; //Is there a policy to force Active desktop to be ON?
  57. BOOL _fSelectionFromUser; // Is the user making the selection?
  58. DWORD _dwApplyFlags; //Is there a policy to force Active desktop to be ON?
  59. CColorControl _colorControl;
  60. COLORREF _rgbBkgdColor;
  61. void _AddPicturesFromDir(LPCTSTR pszDirName, BOOL fCount, BOOL fShouldAllowHTML);
  62. int _AddAFileToLV(LPCTSTR pszDir, LPTSTR pszFile, UINT nBitmap);
  63. int _FindWallpaper(LPCTSTR pszFile);
  64. HRESULT _SetNewWallpaper(IN LPCTSTR pszFile, IN BOOL fUpdateThemePage);
  65. void _UpdatePreview(IN WPARAM flags, IN BOOL fUpdateThemePage);
  66. void _EnableControls(void);
  67. int _GetImageIndex(LPCTSTR pszFile);
  68. static int CALLBACK _SortBackgrounds(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort);
  69. HRESULT _LoadState(void);
  70. HRESULT _LoadIconState(void);
  71. HRESULT _LoadDesktopOptionsState(void);
  72. HRESULT _SaveIconState(void);
  73. HRESULT _SaveDesktopOptionsState(void);
  74. HRESULT _GetIconPath(IN CLSID clsid, IN LPCWSTR pszName, IN BOOL fOldIcon, IN LPWSTR pszPath, IN DWORD cchSize);
  75. HRESULT _SetIconPath(IN CLSID clsid, IN LPCWSTR pszName, IN LPCWSTR pszPath, IN int nResourceID);
  76. void _OnInitDialog(HWND hwnd);
  77. void _OnNotify(LPNMHDR lpnm);
  78. void _OnCommand(HWND hdlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
  79. void _OnDestroy(void);
  80. HRESULT _OnApply(void);
  81. HRESULT _AddFilesToList(void);
  82. HRESULT _AddPicturesFromDirRecursively(IN LPCTSTR pszDirName, BOOL fCount, BOOL fShouldAllowHTML);
  83. HRESULT _GetHardDirThemesDir(LPTSTR pszPath, DWORD cchSize);
  84. HRESULT _GetKidsThemesDir(LPTSTR pszPath, DWORD cchSize);
  85. HRESULT _GetPlus95ThemesDir(LPTSTR pszPath, DWORD cchSize);
  86. HRESULT _GetPlus98ThemesDir(LPTSTR pszPath, DWORD cchSize);
  87. HRESULT _StartSizeChecker(void);
  88. DWORD _SizeCheckerThreadProc(void);
  89. static DWORD CALLBACK SizeCheckerThreadProc(LPVOID pvThis) { return ((CBackPropSheetPage *) pvThis)->_SizeCheckerThreadProc(); };
  90. private:
  91. UINT _cRef; // Reference count
  92. BOOL _fThemePreviewCreated;
  93. IThemePreview* _pThemePreview;
  94. LPTSTR _pszOriginalFile; // If we are using a temp file, this is the original file selected. (non-.bmp). This updates as the user selects different files.
  95. LPTSTR _pszOrigLastApplied; // Same as _pszOriginalFile except it doesn't change until apply is pressed.
  96. LPWSTR _pszWallpaperInUse; // If using a temp file, keep the name in use so we don't stomp it while the user is previewing other files.
  97. LPWSTR _pszLastSourcePath; // This will always be the last wallpaper set and it will be the pre-converted path.
  98. FILETIME _ftLastWrite; // The date that the original file was last written to.
  99. BOOL _fWallpaperChanged; // Did another tab change the wallpaper?
  100. IMruDataList * _pSizeMRU; // MRU of Background wallpapers.
  101. BOOL _fScanFinished; // Did we finish the background scan?
  102. BOOL _fInitialized; //
  103. int _nFileCount; // This is used when counting how many pictures are in the "My Pictures" folder.
  104. int _nFileMax; // This is used when counting how many pictures are in the "My Pictures" folder.
  105. // These objects are owned by the background thread.
  106. IMruDataList * _pSizeMRUBk; // WARNING: Owned by SizeCheckerThreadProc background thread.
  107. IShellImageDataFactory * _pImgFactBk; // Image factory used to compute size of background image to decide to default to tile or stretch
  108. // Private Member Functions
  109. HRESULT _LoadTempWallpaperSettings(IN LPCWSTR pszWallpaperFile);
  110. HRESULT _LaunchAdvancedDisplayProperties(HWND hwnd);
  111. INT_PTR _BackgroundDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
  112. HRESULT _SetNewWallpaperTile(IN DWORD dwMode, IN BOOL fUpdateThemePage);
  113. HRESULT _BrowseForBackground(void);
  114. HRESULT _LoadBackgroundColor(IN BOOL fInit);
  115. HRESULT _Initialize(void);
  116. BOOL _DoesDirHaveMoreThanMax(LPCTSTR pszPath, int nMax);
  117. DWORD _GetStretchMode(IN LPCTSTR pszPath);
  118. HRESULT _GetMRUObject(IMruDataList ** ppSizeMRU);
  119. HRESULT _CalcSizeFromDir(IN LPCTSTR szPath, IN OUT DWORD * pdwAdded, IN BOOL fRecursive);
  120. HRESULT _CalcSizeForFile(IN LPCTSTR pszPath, IN WIN32_FIND_DATA * pfdFile, IN OUT DWORD * pdwAdded);
  121. static INT_PTR CALLBACK BackgroundDlgProc(HWND hDlg, UINT uMessage, WPARAM wParam, LPARAM lParam);
  122. };
  123. #endif