/** * @file XTMemDC.h * * @copyright * (c) 1998-2025 Codejock Software, All Rights Reserved. * * This source file is the property of Codejock Software and must not be * redistributed by any means without the explicit written permission of * Codejock Software. * * The use of this source code is governed by the terms and conditions specified * in the Toolkit Pro license agreement. Codejock Software grants you, as a * single software developer, the limited right to use this software on one * computer only. * * Contact Information: * support@codejock.com * http://www.codejock.com * */ //{{AFX_CODEJOCK_PRIVATE #if !defined(__XTMEMDC_H__) # define __XTMEMDC_H__ //}}AFX_CODEJOCK_PRIVATE # if _MSC_VER > 1000 # pragma once # endif // _MSC_VER > 1000 # include "Common/Base/Diagnostic/XTPDisableNoisyWarnings.h" //=========================================================================== // Summary: // CXTMemDC is a CDC derived class. CXTMemDC is an extension of CDC // that helps eliminate screen flicker when windows are resized, by // painting to an off screen bitmap. The class then uses CDC::BitBlt // to copy the bitmap back into the current device context after all // items have been painted. //=========================================================================== class _XTP_EXT_CLASS CXTMemDC : public CDC { DECLARE_DYNAMIC(CXTMemDC) public: //----------------------------------------------------------------------- // Summary: // Constructs a CXTMemDC object used for flicker free drawing. // Parameters: // pDC - A Pointer to the current device context. // rect - Represents the size of the area to paint. // crBack - An RGB color value that represents the background color. If // no value is specified the system face color for three // dimensional display elements is used. // bHorz - If crBack contains gradient colors indicates the direction // of the gradient fill. //----------------------------------------------------------------------- CXTMemDC(CDC* pDC, const CRect& rect, CXTPPaintManagerColorGradient crBack = GetXtremeColor(COLOR_3DFACE), BOOL bHorz = FALSE); //----------------------------------------------------------------------- // Summary: // Destroys a CXTMemDC object, handles cleanup and deallocation //----------------------------------------------------------------------- virtual ~CXTMemDC(); public: //----------------------------------------------------------------------- // Summary: // This member function is called to set the valid flag to false // so that the off screen device context will not be drawn. //----------------------------------------------------------------------- void Discard(); //----------------------------------------------------------------------- // Summary: // This member function gets content from the given DC //----------------------------------------------------------------------- void FromDC(); //----------------------------------------------------------------------- // Summary: // This member function retrieves a reference to the CBitmap // object associated with the memory device context. // Returns: // A reference to the CBitmap object associated with the memory // device context. //----------------------------------------------------------------------- CBitmap& GetBitmap(); //----------------------------------------------------------------------- // Summary: // Call this member function to determine if memory was allocated and // the device context was successfully created. // Returns: // TRUE if the device context is valid, otherwise FALSE. //----------------------------------------------------------------------- BOOL IsValid() const; protected: CDC* m_pDC; // Saves the CDC passed in constructor. BOOL m_bValid; // Flag used for autodraw in destructor. CRect m_rc; // Rectangle of the drawing area. CBitmap m_bitmap; // Off screen bitmap. HBITMAP m_hOldBitmap; // Original GDI object. }; # include "Common/Base/Diagnostic/XTPEnableNoisyWarnings.h" #endif // #if !defined(__XTMEMDC_H__)