|
#ifndef __Common_h__
#define __Common_h__
#include "StdAfx.h"
#include <time.h>
/*
Data types
*/
typedef basic_string< TCHAR > String;
/*
Global functions
*/
BOOL OleDate2Tm(DATE dtSrc, struct tm& tmDest);
BOOL Tm2OleDate(struct tm& tmSrc, DATE& dtDest);
/*
Used for automatic saving and restoring DC contexts
*/
class CSaveDC
{
public:
CSaveDC( HDC dc )
{
m_bRestored = false;
m_hDC = dc;
m_nID = ::SaveDC( dc );
}
void RestoreDC()
{
::RestoreDC( m_hDC, m_nID );
m_bRestored = true;
}
~CSaveDC()
{
if( !m_bRestored )
{
RestoreDC();
}
}
private:
HDC m_hDC;
int m_nID;
bool m_bRestored;
};
/*
Used for automatic management of GDI objects
*/
template < class GDIObjectType >
class CGDIObject
{
public:
CGDIObject( GDIObjectType hGDIObject = NULL )
{
_ASSERTE( hGDIObject );
m_hGDIObject = hGDIObject;
}
CGDIObject( const CGDIObject< GDIObjectType >& gdiObject )
{
/*
Do not copy this object
*/
_ASSERTE( FALSE );
}
~CGDIObject()
{
_ASSERTE( m_hGDIObject );
::DeleteObject( m_hGDIObject );
}
CGDIObject< GDIObjectType >& operator=( const CGDIObject< GDIObjectType >& gdiObject )
{
/*
Do not assign this object
*/
_ASSERTE( FALSE );
return *this;
}
operator GDIObjectType()
{
return static_cast< GDIObjectType >( m_hGDIObject );
}
private:
GDIObjectType m_hGDIObject;
};
#endif // __Common_h__
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.