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.

156 lines
3.9 KiB

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