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.

114 lines
3.3 KiB

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