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.

181 lines
4.6 KiB

  1. // About.cpp
  2. //
  3. // The About window implementation.
  4. //
  5. // Copyright (c) 1998-1999 Microsoft Corporation
  6. #include "StdAfx.h"
  7. #include <ntverp.h>
  8. #include "About.h"
  9. #include "resrc1.h"
  10. /*
  11. * LoadAboutString - Retrieves the string enumerated nResourceID from
  12. * the StringTable in resource file MSInfo.rc, returning an
  13. * allocated pointer in pAboutData.
  14. *
  15. * Return codes:
  16. * E_POINTER - Invalid pAboutData pointer.
  17. * E_OUTOFMEMORY - Failed CoTaskMemAlloc
  18. * S_OK - Successful completion.
  19. *
  20. * Notes:
  21. * The memory pointed to by lpAboutData will need to be freed with
  22. * CoMemTaskFree.
  23. *
  24. * History: a-jsari 8/26/97 Initial version
  25. */
  26. HRESULT CAboutImpl::LoadAboutString(UINT nResourceID, LPOLESTR *pAboutData)
  27. {
  28. if (pAboutData == NULL)
  29. return E_POINTER;
  30. CString s;
  31. // Needed for Loadstring
  32. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  33. s.LoadString(nResourceID);
  34. *pAboutData = reinterpret_cast<LPOLESTR>
  35. (CoTaskMemAlloc((s.GetLength() + 1)* sizeof(wchar_t)));
  36. if (*pAboutData == NULL)
  37. return E_OUTOFMEMORY;
  38. USES_CONVERSION;
  39. wcscpy(*pAboutData, OLESTR_FROM_CSTRING(s));
  40. return S_OK;
  41. }
  42. /*
  43. * GetSnapinDescription - Return an allocated pointer to the Resource file
  44. * String Table's IDS_DESCRIPTION string in lpDescription.
  45. *
  46. * Return codes:
  47. * E_POINTER - Invalid lpAboutData pointer.
  48. * E_OUTOFMEMORY - Failed CoTaskMemAlloc
  49. * S_OK - Successful completion.
  50. *
  51. * Notes:
  52. * The memory pointed to by lpDescription will need to be freed with
  53. * CoMemTaskFree.
  54. *
  55. * History: a-jsari 8/26/97 Initial version.
  56. */
  57. STDMETHODIMP CAboutImpl::GetSnapinDescription(LPOLESTR *lpDescription)
  58. {
  59. return LoadAboutString(IDS_ROOT_NODE_DESCRIPTION, lpDescription);
  60. }
  61. /*
  62. * GetProvider - Return an allocated pointer to the Resource file
  63. * String Table's IDS_DESCRIPTION string in lpProvider.
  64. *
  65. * Return codes:
  66. * E_POINTER - Invalid lpAboutData pointer.
  67. * E_OUTOFMEMORY - Failed CoTaskMemAlloc
  68. * S_OK - Successful completion.
  69. *
  70. * Notes:
  71. * The memory pointed to by lpProvider will need to be freed with
  72. * CoMemTaskFree.
  73. *
  74. * History: a-jsari 8/26/97 Initial version.
  75. */
  76. STDMETHODIMP CAboutImpl::GetProvider(LPOLESTR *lpProvider)
  77. {
  78. return LoadAboutString(IDS_COMPANY, lpProvider);
  79. }
  80. /*
  81. * GetSnapinVersion - Return an allocated pointer to the Resource file
  82. * String Table's IDS_VERSION string in lpVersion.
  83. *
  84. * Return codes:
  85. * E_POINTER - Invalid lpAboutData pointer.
  86. * E_OUTOFMEMORY - Failed CoTaskMemAlloc
  87. * S_OK - Successful completion.
  88. *
  89. * Notes:
  90. * The memory pointed to by lpVersion will need to be freed with
  91. * CoMemTaskFree.
  92. *
  93. * History: a-jsari 8/26/97 Initial version.
  94. */
  95. STDMETHODIMP CAboutImpl::GetSnapinVersion(LPOLESTR *lpVersion)
  96. {
  97. ASSERT(lpVersion != NULL);
  98. USES_CONVERSION;
  99. LPTSTR szVersion = A2T(VER_PRODUCTVERSION_STRING);
  100. *lpVersion = (LPOLESTR)::CoTaskMemAlloc((::_tcslen(szVersion) + 1) * sizeof(TCHAR));
  101. if (*lpVersion == NULL) return E_OUTOFMEMORY;
  102. ::_tcscpy(*lpVersion, szVersion);
  103. return S_OK;
  104. }
  105. /*
  106. * GetSnapinImage - Takes the Application Icon resource and puts it in
  107. * hAppIcon.
  108. *
  109. * Return Codes:
  110. * E_POINTER - Invalid hAppIcon pointer.
  111. * E_FAIL - Failed LoadIcon.
  112. * S_OK - Successful completion
  113. *
  114. * History: a-jsari 8/26/97 Initial version.
  115. */
  116. STDMETHODIMP CAboutImpl::GetSnapinImage(HICON *hAppIcon)
  117. {
  118. if (hAppIcon == NULL)
  119. return E_POINTER;
  120. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  121. *hAppIcon = LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDI_MSINFO));
  122. ASSERT(*hAppIcon != NULL);
  123. return (*hAppIcon != NULL) ? S_OK : E_FAIL;
  124. }
  125. /*
  126. * GetStaticFolderImage - Returns pointers to the
  127. *
  128. * Return Codes:
  129. * E_POINTER - Invalid hSmallImage, hSmallImageOpen, hLargeImage, or cLargeMask
  130. * pointer.
  131. * S_OK - Always
  132. *
  133. * History: a-jsari 8/26/97 Initial version.
  134. */
  135. STDMETHODIMP CAboutImpl::GetStaticFolderImage(HBITMAP *hSmallImage,
  136. HBITMAP *hSmallImageOpen,
  137. HBITMAP *hLargeImage,
  138. COLORREF *cLargeMask)
  139. {
  140. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  141. HINSTANCE hInst = ::AfxGetInstanceHandle();
  142. if (hSmallImage == NULL || hSmallImageOpen == NULL || hLargeImage == NULL || cLargeMask == NULL)
  143. return E_POINTER;
  144. HBITMAP hSmall = (HBITMAP) LoadBitmap(hInst, MAKEINTRESOURCE(IDB_ICON16));
  145. if (hSmall)
  146. *hSmallImage = hSmall;
  147. hSmall = (HBITMAP) LoadBitmap(hInst, MAKEINTRESOURCE(IDB_ICON16));
  148. if (hSmall)
  149. *hSmallImageOpen = hSmall;
  150. HBITMAP hNormal = (HBITMAP) LoadBitmap(hInst, MAKEINTRESOURCE(IDB_ICON32));
  151. if (hNormal)
  152. *hLargeImage = hNormal;
  153. *cLargeMask = RGB(255,0,255); // background mask
  154. return S_OK;
  155. }