XTMemDC.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. // Ignore
  2. // XTMemDC.h interface for the CXTMemDC class.
  3. //
  4. // This file is a part of the Xtreme Toolkit for MFC.
  5. // ?998-2002 Codejock Software, All Rights Reserved.
  6. //
  7. // This source code can only be used under the terms and conditions
  8. // outlined in the accompanying license agreement.
  9. //
  10. // support@codejock.com
  11. // http://www.codejock.com
  12. //
  13. //////////////////////////////////////////////////////////////////////
  14. //:End Ignore
  15. #if !defined(__XTMEMDC_H__)
  16. #define __XTMEMDC_H__
  17. //:Ignore
  18. #if _MSC_VER > 1000
  19. #pragma once
  20. #endif // _MSC_VER > 1000
  21. //:End Ignore
  22. /////////////////////////////////////////////////////////////////////////////
  23. // CXTMemDC is a CDC extension that helps eliminate screen flicker when windows
  24. // are resized, by painting to an off screen bitmap. The class then uses
  25. // CDC::BitBlt to copy the bitmap back into the current device context after all
  26. // items have been painted.
  27. class CXTMemDC : public CDC
  28. {
  29. public:
  30. DECLARE_DYNAMIC(CXTMemDC);
  31. // Constructs a CXTMemDC object.
  32. CXTMemDC(
  33. // Points to the current device context.
  34. CDC* pDC,
  35. // Represents the size of the area to paint.
  36. const CRect& rect,
  37. // RGB value that represents the background color
  38. // of the area to paint, defaults to COLOR_3DFACE. Pass in
  39. // a value of -1 to disable background painting.
  40. COLORREF clrColor/*=xtAfxData.clr3DFace*/);
  41. // Destroys a CXTMemDC object, handles cleanup and de-allocation.
  42. virtual ~CXTMemDC();
  43. void Discard()
  44. {
  45. m_bValid = FALSE;
  46. }
  47. // Get content from the given DC
  48. void FromDC()
  49. {
  50. BitBlt(0, 0, m_rc.Width(), m_rc.Height(), m_pDC,
  51. m_rc.left, m_rc.top, SRCCOPY);
  52. }
  53. CBitmap& GetBitmap() { return m_bitmap; }
  54. protected:
  55. CDC* m_pDC; // Saves CDC passed in constructor
  56. CRect m_rc; // Rectangle of drawing area.
  57. CBitmap m_bitmap; // Offscreen bitmap
  58. CBitmap* m_pOldBitmap; // Original GDI object
  59. BOOL m_bValid; // flag for autodraw in dtor
  60. };
  61. /////////////////////////////////////////////////////////////////////////////
  62. //{{AFX_INSERT_LOCATION}}
  63. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  64. #endif // #if !defined(__XTMEMDC_H__)