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.

160 lines
3.9 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1998
  6. //
  7. // File: stdabout.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. /////////////////////////////////////////////////////////////////////
  11. // StdAbout.cpp
  12. //
  13. // Implementation of the ISnapinAbout interface
  14. //
  15. // HISTORY
  16. // 31-Jul-97 t-danm Creation.
  17. /////////////////////////////////////////////////////////////////////
  18. #include "stdafx.h"
  19. HRESULT
  20. HrLoadOleString(UINT uStringId, // IN: String Id to load from the resource
  21. OUT LPOLESTR * ppaszOleString) // OUT: Pointer to pointer to allocated OLE string
  22. {
  23. if (ppaszOleString == NULL)
  24. {
  25. TRACE0("HrLoadOleString() - ppaszOleString is NULL.\n");
  26. return E_POINTER;
  27. }
  28. CString strT; // Temporary string
  29. AFX_MANAGE_STATE(AfxGetStaticModuleState()); // Needed for LoadString()
  30. VERIFY( strT.LoadString(uStringId) );
  31. *ppaszOleString = reinterpret_cast<LPOLESTR>
  32. (CoTaskMemAlloc((strT.GetLength() + 1)* sizeof(wchar_t)));
  33. if (*ppaszOleString == NULL)
  34. {
  35. return E_OUTOFMEMORY;
  36. }
  37. USES_CONVERSION;
  38. wcscpy(OUT *ppaszOleString, T2OLE((LPTSTR)(LPCTSTR)strT));
  39. return S_OK;
  40. } // HrLoadOleString()
  41. CSnapinAbout::CSnapinAbout() :
  42. hBitmapSmallImage(0),
  43. hBitmapSmallImageOpen(0),
  44. hBitmapLargeImage(0)
  45. {
  46. }
  47. CSnapinAbout::~CSnapinAbout()
  48. {
  49. if (hBitmapSmallImage)
  50. {
  51. DeleteObject(hBitmapSmallImage);
  52. hBitmapSmallImage = 0;
  53. }
  54. if (hBitmapSmallImageOpen)
  55. {
  56. DeleteObject(hBitmapSmallImageOpen);
  57. hBitmapSmallImageOpen = 0;
  58. }
  59. if (hBitmapLargeImage)
  60. {
  61. DeleteObject(hBitmapLargeImage);
  62. hBitmapLargeImage = 0;
  63. }
  64. }
  65. STDMETHODIMP CSnapinAbout::GetSnapinDescription(OUT LPOLESTR __RPC_FAR *lpDescription)
  66. {
  67. return HrLoadOleString(m_uIdStrDestription, OUT lpDescription);
  68. }
  69. STDMETHODIMP CSnapinAbout::GetProvider(OUT LPOLESTR __RPC_FAR *lpName)
  70. {
  71. return HrLoadOleString(m_uIdStrProvider, OUT lpName);
  72. }
  73. STDMETHODIMP CSnapinAbout::GetSnapinVersion(OUT LPOLESTR __RPC_FAR *lpVersion)
  74. {
  75. return HrLoadOleString(m_uIdStrVersion, OUT lpVersion);
  76. }
  77. STDMETHODIMP CSnapinAbout::GetSnapinImage(OUT HICON __RPC_FAR *hAppIcon)
  78. {
  79. if (hAppIcon == NULL)
  80. return E_POINTER;
  81. AFX_MANAGE_STATE(AfxGetStaticModuleState()); // Required for AfxGetInstanceHandle()
  82. *hAppIcon = ::LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(m_uIdIconImage));
  83. if (*hAppIcon == NULL)
  84. {
  85. ASSERT(FALSE && "Unable to load icon");
  86. return E_FAIL;
  87. }
  88. return S_OK;
  89. }
  90. STDMETHODIMP CSnapinAbout::GetStaticFolderImage(
  91. OUT HBITMAP __RPC_FAR *hSmallImage,
  92. OUT HBITMAP __RPC_FAR *hSmallImageOpen,
  93. OUT HBITMAP __RPC_FAR *hLargeImage,
  94. OUT COLORREF __RPC_FAR *crMask)
  95. {
  96. ASSERT(hSmallImage != NULL);
  97. ASSERT(hSmallImageOpen != NULL);
  98. ASSERT(hLargeImage != NULL);
  99. ASSERT(crMask != NULL);
  100. AFX_MANAGE_STATE(AfxGetStaticModuleState()); // Required for AfxGetInstanceHandle()
  101. HINSTANCE hInstance = AfxGetInstanceHandle();
  102. if (!hBitmapSmallImage)
  103. {
  104. hBitmapSmallImage = ::LoadBitmap(hInstance, MAKEINTRESOURCE(m_uIdBitmapSmallImage));
  105. }
  106. ASSERT(hBitmapSmallImage);
  107. *hSmallImage = hBitmapSmallImage;
  108. if (!hBitmapSmallImageOpen)
  109. {
  110. hBitmapSmallImageOpen = ::LoadBitmap(hInstance, MAKEINTRESOURCE(m_uIdBitmapSmallImageOpen));
  111. }
  112. ASSERT(hBitmapSmallImageOpen);
  113. *hSmallImageOpen = hBitmapSmallImageOpen;
  114. if (!hBitmapLargeImage)
  115. {
  116. hBitmapLargeImage = ::LoadBitmap(hInstance, MAKEINTRESOURCE(m_uIdBitmapLargeImage));
  117. }
  118. ASSERT(hBitmapLargeImage);
  119. *hLargeImage = hBitmapLargeImage;
  120. *crMask = m_crImageMask;
  121. #ifdef _DEBUG
  122. if (NULL == *hSmallImage || NULL == *hSmallImageOpen || NULL == *hLargeImage)
  123. {
  124. TRACE0("WRN: CSnapinAbout::GetStaticFolderImage() - Unable to load all the bitmaps.\n");
  125. return E_FAIL;
  126. }
  127. #endif
  128. return S_OK;
  129. }