ClipFormatQListCtrl.cpp 858 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. #include "stdafx.h"
  2. #include "ClipFormatQListCtrl.h"
  3. #include "BitmapHelper.h"
  4. CClipFormatQListCtrl::CClipFormatQListCtrl(void)
  5. {
  6. m_clipRow = -1;
  7. m_convertedToSmallImage = false;
  8. }
  9. CClipFormatQListCtrl::~CClipFormatQListCtrl(void)
  10. {
  11. }
  12. HGLOBAL CClipFormatQListCtrl::GetDib(CDC *pDc, int height)
  13. {
  14. if(m_cfType != CF_DIB)
  15. {
  16. return NULL;
  17. }
  18. if(m_convertedToSmallImage)
  19. {
  20. return m_hgData;
  21. }
  22. m_convertedToSmallImage = true;
  23. CBitmap Bitmap;
  24. if( !CBitmapHelper::GetCBitmap(this, pDc, &Bitmap, height) )
  25. {
  26. Bitmap.DeleteObject();
  27. // the data is useless, so free it.
  28. this->Free();
  29. return FALSE;
  30. }
  31. // delete the large image data loaded from the db
  32. this->Free();
  33. //Convert the smaller bitmap back to a dib
  34. HPALETTE hPal = NULL;
  35. this->m_hgData = CBitmapHelper::hBitmapToDIB((HBITMAP)Bitmap, BI_RGB, hPal);
  36. return this->m_hgData;
  37. }