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.

171 lines
5.3 KiB

  1. // --------------------------------------------------------------------------
  2. // Module Name: ThemeSection.cpp
  3. //
  4. // Copyright (c) 2000, Microsoft Corporation
  5. //
  6. // Class that wraps CUxThemeFile. CUxThemeFile automatically closes the section
  7. // member variable handle. This makes usage of the class difficult because
  8. // it doesn't duplicate the handle but it takes ownership. It does declare
  9. // the handle as a PUBLIC member variable so we capitalize on this poor
  10. // design. This class wraps CUxThemeFile to make the life of users of this
  11. // class easier by not having them worry about closing the handles or not.
  12. // When you use this class the handle is NOT closed.
  13. //
  14. // History: 2000-11-22 vtan created
  15. // --------------------------------------------------------------------------
  16. #include "stdafx.h"
  17. #include "ThemeSection.h"
  18. #define goto !!DO NOT USE GOTO!! - DO NOT REMOVE THIS ON PAIN OF DEATH
  19. // --------------------------------------------------------------------------
  20. // CThemeSection::CThemeSection
  21. //
  22. // Arguments: <none>
  23. //
  24. // Returns: <none>
  25. //
  26. // Purpose: Constructor for CThemeSection.
  27. //
  28. // History: 2000-11-22 vtan created
  29. // --------------------------------------------------------------------------
  30. CThemeSection::CThemeSection (void)
  31. {
  32. }
  33. // --------------------------------------------------------------------------
  34. // CThemeSection::~CThemeSection
  35. //
  36. // Arguments: <none>
  37. //
  38. // Returns: <none>
  39. //
  40. // Purpose: Destructor for CThemeSection. This is TOTALLY BOGUS having to
  41. // set an internal member variable contents to NULL to prevent
  42. // it from releasing resources but the rest of the code relies
  43. // on the auto-release behavior without duplication of the
  44. // handle. This is done to protect this class from that hassle.
  45. //
  46. // History: 2000-11-22 vtan created
  47. // --------------------------------------------------------------------------
  48. CThemeSection::~CThemeSection (void)
  49. {
  50. _themeFile._hMemoryMap = NULL;
  51. }
  52. // --------------------------------------------------------------------------
  53. // CThemeSection::operator CUxThemeFile*
  54. //
  55. // Arguments: <none>
  56. //
  57. // Returns: CUxThemeFile*
  58. //
  59. // Purpose: Automagic operator to convert from CThemeSection to
  60. // CUxThemeFile* which keeps current usage transparent.
  61. //
  62. // History: 2000-11-22 vtan created
  63. // --------------------------------------------------------------------------
  64. CThemeSection::operator CUxThemeFile* (void)
  65. {
  66. return(&_themeFile);
  67. }
  68. // --------------------------------------------------------------------------
  69. // CThemeSection::Open
  70. //
  71. // Arguments: hSection = Section to use.
  72. // dwViewAccess = desired access for mapped view.
  73. //
  74. // Returns: HRESULT
  75. //
  76. // Purpose: Pass thru to CUxThemeFile::OpenFile.
  77. //
  78. // History: 2000-11-22 vtan created
  79. // 2002-03-24 scotthan add dwViewAccess arg.
  80. // --------------------------------------------------------------------------
  81. HRESULT CThemeSection::Open (HANDLE hSection, DWORD dwViewAccess /* FILE_MAP_READ*/)
  82. {
  83. return(_themeFile.OpenFromHandle(hSection, dwViewAccess));
  84. }
  85. // --------------------------------------------------------------------------
  86. // CThemeSection::ValidateData
  87. //
  88. // Arguments: fFullCheck = Perform a full check?
  89. //
  90. // Returns: HRESULT
  91. //
  92. // Purpose: Pass thru to CUxThemeFile::ValidateThemeData.
  93. //
  94. // History: 2000-11-22 vtan created
  95. // --------------------------------------------------------------------------
  96. HRESULT CThemeSection::ValidateData (bool fFullCheck)
  97. {
  98. return(_themeFile.ValidateThemeData(fFullCheck));
  99. }
  100. // --------------------------------------------------------------------------
  101. // CThemeSection::CreateFromSection
  102. //
  103. // Arguments: hSection = Section to duplicate.
  104. //
  105. // Returns: HRESULT
  106. //
  107. // Purpose: Pass thru to CUxThemeFile::CreateFromSection.
  108. //
  109. // History: 2000-11-22 vtan created
  110. // --------------------------------------------------------------------------
  111. HRESULT CThemeSection::CreateFromSection (HANDLE hSection)
  112. {
  113. return(_themeFile.CreateFromSection(hSection));
  114. }
  115. // --------------------------------------------------------------------------
  116. // CThemeSection::Get
  117. //
  118. // Arguments: <none>
  119. //
  120. // Returns: HANDLE
  121. //
  122. // Purpose: Returns the handle of the CUxThemeFile object. Because this
  123. // class always NULLs out the handle it will get leaked. Once
  124. // this handle is returned the caller owns the handle.
  125. //
  126. // History: 2000-11-22 vtan created
  127. // --------------------------------------------------------------------------
  128. HANDLE CThemeSection::Get (void) const
  129. {
  130. return(_themeFile._hMemoryMap);
  131. }
  132. // --------------------------------------------------------------------------
  133. // CThemeSection::GetData
  134. //
  135. // Arguments: <none>
  136. //
  137. // Returns: PVOID
  138. //
  139. // Purpose: Returns a pointer to the theme data.
  140. //
  141. // History: 2002-03-24 scotthan created
  142. // --------------------------------------------------------------------------
  143. PVOID CThemeSection::GetData(void)
  144. {
  145. return _themeFile._pbThemeData;
  146. }