Source code of Windows XP (NT5)
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.

153 lines
4.6 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. //
  73. // Returns: HRESULT
  74. //
  75. // Purpose: Pass thru to CUxThemeFile::OpenFile.
  76. //
  77. // History: 2000-11-22 vtan created
  78. // --------------------------------------------------------------------------
  79. HRESULT CThemeSection::Open (HANDLE hSection)
  80. {
  81. return(_themeFile.OpenFromHandle(hSection));
  82. }
  83. // --------------------------------------------------------------------------
  84. // CThemeSection::ValidateData
  85. //
  86. // Arguments: fFullCheck = Perform a full check?
  87. //
  88. // Returns: HRESULT
  89. //
  90. // Purpose: Pass thru to CUxThemeFile::ValidateThemeData.
  91. //
  92. // History: 2000-11-22 vtan created
  93. // --------------------------------------------------------------------------
  94. HRESULT CThemeSection::ValidateData (bool fFullCheck)
  95. {
  96. return(_themeFile.ValidateThemeData(fFullCheck));
  97. }
  98. // --------------------------------------------------------------------------
  99. // CThemeSection::CreateFromSection
  100. //
  101. // Arguments: hSection = Section to duplicate.
  102. //
  103. // Returns: HRESULT
  104. //
  105. // Purpose: Pass thru to CUxThemeFile::CreateFromSection.
  106. //
  107. // History: 2000-11-22 vtan created
  108. // --------------------------------------------------------------------------
  109. HRESULT CThemeSection::CreateFromSection (HANDLE hSection)
  110. {
  111. return(_themeFile.CreateFromSection(hSection));
  112. }
  113. // --------------------------------------------------------------------------
  114. // CThemeSection::Get
  115. //
  116. // Arguments: <none>
  117. //
  118. // Returns: HANDLE
  119. //
  120. // Purpose: Returns the handle of the CUxThemeFile object. Because this
  121. // class always NULLs out the handle it will get leaked. Once
  122. // this handle is returned the caller owns the handle.
  123. //
  124. // History: 2000-11-22 vtan created
  125. // --------------------------------------------------------------------------
  126. HANDLE CThemeSection::Get (void) const
  127. {
  128. return(_themeFile._hMemoryMap);
  129. }