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.

191 lines
6.1 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation 1996-2001.
  5. //
  6. // File: about.cpp
  7. //
  8. // Contents: implementation of CAbout, CSCEAbout, CSCMAbout, CSSAbout,
  9. // CRSOPAbout & CLSAbout
  10. //
  11. //----------------------------------------------------------------------------
  12. #include "stdafx.h"
  13. #include "resource.h"
  14. #include "about.h"
  15. #include <ntverp.h>
  16. #define OUT_VERSION VER_PRODUCTVERSION_STR
  17. /////////////////////////////////////////////////////////////////////
  18. CSCEAbout::CSCEAbout()
  19. {
  20. m_uIdStrProvider = IDS_SNAPINABOUT_PROVIDER;
  21. m_uIdStrVersion = IDS_SNAPINABOUT_VERSION;
  22. m_uIdStrDescription = IDS_SCEABOUT_DESCRIPTION;
  23. m_uIdIconImage = IDI_SCE_APP;
  24. m_uIdBitmapSmallImage = IDB_SCE_SMALL;
  25. m_uIdBitmapSmallImageOpen = IDB_SCE_SMALL;
  26. m_uIdBitmapLargeImage = IDB_SCE_LARGE;
  27. m_crImageMask = RGB(255, 0, 255);
  28. }
  29. CSCMAbout::CSCMAbout()
  30. {
  31. m_uIdStrProvider = IDS_SNAPINABOUT_PROVIDER;
  32. m_uIdStrVersion = IDS_SNAPINABOUT_VERSION;
  33. m_uIdStrDescription = IDS_SCMABOUT_DESCRIPTION;
  34. m_uIdIconImage = IDI_SCE_APP;
  35. m_uIdBitmapSmallImage = IDB_SCE_SMALL;
  36. m_uIdBitmapSmallImageOpen = IDB_SCE_SMALL;
  37. m_uIdBitmapLargeImage = IDB_SCE_LARGE;
  38. m_crImageMask = RGB(255, 0, 255);
  39. }
  40. CSSAbout::CSSAbout()
  41. {
  42. m_uIdStrProvider = IDS_SNAPINABOUT_PROVIDER;
  43. m_uIdStrVersion = IDS_SNAPINABOUT_VERSION;
  44. m_uIdStrDescription = IDS_SSABOUT_DESCRIPTION;
  45. m_uIdIconImage = IDI_SCE_APP;
  46. m_uIdBitmapSmallImage = IDB_SCE_SMALL;
  47. m_uIdBitmapSmallImageOpen = IDB_SCE_SMALL;
  48. m_uIdBitmapLargeImage = IDB_SCE_LARGE;
  49. m_crImageMask = RGB(255, 0, 255);
  50. }
  51. CRSOPAbout::CRSOPAbout()
  52. {
  53. m_uIdStrProvider = IDS_SNAPINABOUT_PROVIDER;
  54. m_uIdStrVersion = IDS_SNAPINABOUT_VERSION;
  55. m_uIdStrDescription = IDS_RSOPABOUT_DESCRIPTION;
  56. m_uIdIconImage = IDI_SCE_APP;
  57. m_uIdBitmapSmallImage = IDB_SCE_SMALL;
  58. m_uIdBitmapSmallImageOpen = IDB_SCE_SMALL;
  59. m_uIdBitmapLargeImage = IDB_SCE_LARGE;
  60. m_crImageMask = RGB(255, 0, 255);
  61. }
  62. CLSAbout::CLSAbout()
  63. {
  64. m_uIdStrProvider = IDS_SNAPINABOUT_PROVIDER;
  65. m_uIdStrVersion = IDS_SNAPINABOUT_VERSION;
  66. m_uIdStrDescription = IDS_LSABOUT_DESCRIPTION;
  67. m_uIdIconImage = IDI_SCE_APP;
  68. m_uIdBitmapSmallImage = IDB_SCE_SMALL;
  69. m_uIdBitmapSmallImageOpen = IDB_SCE_SMALL;
  70. m_uIdBitmapLargeImage = IDB_SCE_LARGE;
  71. m_crImageMask = RGB(255, 0, 255);
  72. }
  73. /////////////////////////////////////////////////////////////////////
  74. // HrLoadOleString()
  75. //
  76. // Load a string from the resource and return pointer to allocated
  77. // OLE string.
  78. //
  79. // HISTORY
  80. // 29-Jul-97 t-danm Creation.
  81. //
  82. HRESULT
  83. HrLoadOleString(
  84. UINT uStringId, // IN: String Id to load from the resource
  85. OUT LPOLESTR * ppaszOleString) // OUT: Pointer to pointer to allocated OLE string
  86. {
  87. if (ppaszOleString == NULL) {
  88. TRACE0("HrLoadOleString() - ppaszOleString is NULL.\n");
  89. return E_POINTER;
  90. }
  91. CString strT; // Temporary string
  92. AFX_MANAGE_STATE(AfxGetStaticModuleState()); // Needed for LoadString()
  93. if( IDS_SNAPINABOUT_VERSION == uStringId )
  94. {
  95. strT = OUT_VERSION;
  96. }
  97. else
  98. {
  99. VERIFY( strT.LoadString(uStringId) );
  100. }
  101. *ppaszOleString = reinterpret_cast<LPOLESTR>
  102. (CoTaskMemAlloc((strT.GetLength() + 1)* sizeof(wchar_t)));
  103. if (*ppaszOleString == NULL) {
  104. return E_OUTOFMEMORY;
  105. }
  106. USES_CONVERSION;
  107. wcscpy(OUT *ppaszOleString, T2OLE((LPTSTR)(LPCTSTR)strT));
  108. return S_OK;
  109. } // HrLoadOleString()
  110. STDMETHODIMP CAbout::GetSnapinDescription(OUT LPOLESTR __RPC_FAR *lpDescription)
  111. {
  112. return HrLoadOleString(m_uIdStrDescription, OUT lpDescription);
  113. }
  114. STDMETHODIMP CAbout::GetProvider(OUT LPOLESTR __RPC_FAR *lpName)
  115. {
  116. return HrLoadOleString(m_uIdStrProvider, OUT lpName);
  117. }
  118. STDMETHODIMP CAbout::GetSnapinVersion(OUT LPOLESTR __RPC_FAR *lpVersion)
  119. {
  120. return HrLoadOleString(m_uIdStrVersion, OUT lpVersion);
  121. }
  122. STDMETHODIMP CAbout::GetSnapinImage(OUT HICON __RPC_FAR *hAppIcon)
  123. {
  124. if (hAppIcon == NULL)
  125. return E_POINTER;
  126. AFX_MANAGE_STATE(AfxGetStaticModuleState()); // Required for AfxGetInstanceHandle()
  127. *hAppIcon = ::LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(m_uIdIconImage));
  128. if (*hAppIcon == NULL) {
  129. ASSERT(FALSE && "Unable to load icon");
  130. return E_FAIL;
  131. }
  132. return S_OK;
  133. }
  134. STDMETHODIMP CAbout::GetStaticFolderImage(
  135. OUT HBITMAP __RPC_FAR *hSmallImage,
  136. OUT HBITMAP __RPC_FAR *hSmallImageOpen,
  137. OUT HBITMAP __RPC_FAR *hLargeImage,
  138. OUT COLORREF __RPC_FAR *crMask)
  139. {
  140. ASSERT(hSmallImage != NULL);
  141. ASSERT(hSmallImageOpen != NULL);
  142. ASSERT(hLargeImage != NULL);
  143. ASSERT(crMask != NULL);
  144. AFX_MANAGE_STATE(AfxGetStaticModuleState()); // Required for AfxGetInstanceHandle()
  145. HINSTANCE hInstance = AfxGetInstanceHandle();
  146. //Raid #379315, 4/27/2001
  147. *hSmallImage = (HBITMAP)::LoadImage(
  148. hInstance,
  149. MAKEINTRESOURCE(m_uIdBitmapSmallImage),
  150. IMAGE_BITMAP,
  151. 0, 0,
  152. LR_SHARED
  153. );
  154. *hSmallImageOpen = (HBITMAP)::LoadImage(
  155. hInstance,
  156. MAKEINTRESOURCE(m_uIdBitmapSmallImageOpen),
  157. IMAGE_BITMAP,
  158. 0, 0,
  159. LR_SHARED
  160. );
  161. *hLargeImage = (HBITMAP)::LoadImage(
  162. hInstance,
  163. MAKEINTRESOURCE(m_uIdBitmapLargeImage),
  164. IMAGE_BITMAP,
  165. 0, 0,
  166. LR_SHARED
  167. );
  168. *crMask = m_crImageMask;
  169. #ifdef _DEBUG
  170. if (NULL == *hSmallImage || NULL == *hSmallImageOpen || NULL == *hLargeImage) {
  171. TRACE0("WRN: CAbout::GetStaticFolderImage() - Unable to load all the bitmaps.\n");
  172. return E_FAIL;
  173. }
  174. #endif
  175. return S_OK;
  176. }