ClipFormatQListCtrl.cpp 956 B

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