ImageListDyn.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // ImageListDyn.cpp: implementation of the CImageListDyn class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include "stdafx.h"
  5. #include "DataManager.h"
  6. #include "ImageListDyn.h"
  7. #ifdef _DEBUG
  8. #undef THIS_FILE
  9. static char THIS_FILE[]=__FILE__;
  10. #define new DEBUG_NEW
  11. #endif
  12. //////////////////////////////////////////////////////////////////////
  13. // Construction/Destruction
  14. //////////////////////////////////////////////////////////////////////
  15. CImageListDyn::CImageListDyn()
  16. {
  17. }
  18. CImageListDyn::~CImageListDyn()
  19. {
  20. CImageList::DeleteImageList();
  21. }
  22. int CImageListDyn::GetImage(CString strIconFile)
  23. {
  24. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  25. // ASSERT(FALSE);
  26. int nImage = -1;
  27. if(!m_mapIcons.Lookup(strIconFile, (void*&)nImage))
  28. {
  29. CString strIconPath = strIconFile;
  30. HICON hIcon = (HICON)LoadImage(NULL, strIconPath, IMAGE_ICON, 16, 16, LR_LOADFROMFILE|LR_SHARED|LR_LOADTRANSPARENT);
  31. if(hIcon == NULL)
  32. {
  33. CString strIcon = GetMapDir("Icon");
  34. strIconPath = theApp.m_strDllPath + "\\" + strIcon + "\\" + strIconFile + ".ico";
  35. hIcon = (HICON)LoadImage(NULL, strIconPath, IMAGE_ICON, 16, 16, LR_LOADFROMFILE|LR_SHARED|LR_LOADTRANSPARENT);
  36. }
  37. if(hIcon != NULL)
  38. {
  39. nImage = this->Add(hIcon);
  40. //DestroyIcon(hIcon);
  41. m_mapIcons.SetAt(strIconFile, (LPVOID)nImage);
  42. }
  43. }
  44. return nImage;
  45. }
  46. BOOL CImageListDyn::Create()
  47. {
  48. // return CImageList::Create(IDB_BITMAP_TREE_IMAGE, 16, 16, RGB(255,255,255));
  49. return CImageList::Create(16, 16, ILC_COLOR32, 0, 32);
  50. }