// Created by Larry Leonard, Definitive Solutions, Inc. #if !defined(GENERICATLH_) #define GENERICATLH_ #pragma once #include "MyAtlLog.h" #include #import using namespace MSXML; #ifdef _ATL_MIN_CRT #error C RunTime is required by this class! #endif ///////////////////////////////////////////////////////////////////////////// // Disabled compiler warnings. //#pragma warning (disable : 4245) // 'Conversion' : conversion from 'type1' to 'type2', signed/unsigned mismatch //#pragma warning (disable : 4800) // Forcing value to bool 'true' or 'false' (performance warning) ///////////////////////////////////////////////////////////////////////////// // Defines. // DEBUG_ONLY #ifdef _DEBUG #define DEBUG_ONLY(f) (f) #else #define DEBUG_ONLY(f) ((void)0) #endif // VERIFY #ifndef VERIFY #ifdef _DEBUG #define VERIFY(f) ATLASSERT(f) #else #define VERIFY(f) ((void)(f)) #endif #endif // Colors. #define RGB_BLACK (RGB( 0, 0, 0)) #define RGB_WHITE (RGB(255, 255, 255)) #define RGB_RED (RGB(255, 0, 0)) #define RGB_RED_DARK (RGB(128, 0, 0)) #define RGB_GREEN (RGB( 0, 255, 0)) #define RGB_GREEN_DARK (RGB( 0, 128, 0)) #define RGB_BLUE (RGB( 0, 0, 255)) #define RGB_BLUE_DARK (RGB( 0, 0, 128)) #define RGB_YELLOW (RGB(255, 255, 128)) #define RGB_YELLOW_LIGHT (RGB(255, 255, 192)) #define RGB_CYAN (RGB( 0, 255, 255)) #define RGB_CYAN_LIGHT (RGB(128, 255, 255)) #define RGB_CYAN_DARK (RGB( 0, 128, 128)) #define RGB_PURPLE (RGB(128, 0, 128)) #define RGB_GRAY (RGB(192, 192, 192)) #define RGB_GRAY_DARK (RGB(128, 128, 128)) ///////////////////////////////////////////////////////////////////////////// // Macros. // This macro can be called at the beginning and ending of every // method. It is identical to saying "ASSERT_VALID(); ASSERT_KINDOF();" // but is written like this so that VALIDATE can be a macro. It is useful // as an "early warning" that something has gone wrong with "this" object. #ifndef VALIDATE #ifdef _DEBUG #define VALIDATE /* CURRENTLY UNIMPLEMENTED IN MY ATL STUFF */ #else #define VALIDATE #endif #endif ///////////////////////////////////////////////////////////////////////////// // GenericAtl class - a hodge-podge of utility functions class GenericAtl { // Construction. public: GenericAtl(); virtual ~GenericAtl(); // Declared but not defined. private: GenericAtl(const GenericAtl& rhs); GenericAtl& operator=(const GenericAtl& rhs); // Public data. public: static MyAtlLog TheLog; // Logging file. // Interface. public: static _fsize_t GetFileSize(const string& strPath); static BOOL RemoveFile(const string& strPath); static string FileFromPath(const string& strPath); static const char* GetSysErrorString(); static const char* GetHrErrorString(HRESULT hr); static const char* GetXMLDOMErrorString( const IXMLDOMDocumentPtr& spXMLDOMDocument); static UINT SpinTheMessageLoop(bool bNoDrawing = false, bool bOnlyDrawing = false, UINT uiMsgAllowed = WM_NULL); static string DirFromPath(const string& strPath); /* static int GetHorzPixels(CWnd* pWnd, int nDlgUnits); static int GetVertPixels(CWnd* pWnd, int nDlgUnits); static UINT SpinTheMessageLoop(bool bNoDrawing = false, bool bOnlyDrawing = false, UINT uiMsgAllowed = WM_NULL); static bool TranslateEnvPath(CString& sPathRaw); static CString IntToCommas(int nInt); static CString DoubleToCommas(double dDouble, int nDigitsAfterDecimal = 2); static int CommasToInt(const CString& sCommas); static double CommasToDouble(const CString& sCommas); static double RoundDouble(double dDouble, int nDigitsAfterDecimal = 2); static CString StripNonNumeric(const CString& s); static double Load80BitLongDoubleTo64BitDouble(CArchive& ar); static CString LoadString(UINT uiId); static bool GetFromIniFile(const CString& sIniFile, const CString& sSection, const CString& sEntry, const CString& sDefault, CString& sData, int nSize = MAX_PATH); static CString TitleFromPath(const CString& sPath); static CString DirFromPath(const CString& sPath); static CString DirAndFileFromPath(const CString& sPath); static CString FileFromPath(const CString& sPath); static CString ExtFromPath(const CString& sPath); static _fsize_t GetFileSize(const CString& sPath); static bool IsDirectory(const CString& sPath); static int PointsToLogicalHeight(const CDC* pDC, int nPoints); static int GetJulianDayNumber(const CTime& tim); static void QuickExit(const CString& sFile, int nLine); static CString GetErrorString(); static int ReverseFindOneOf(const CString& s, const CString& sSub, int nStart = -1); static void RGBtoHLS(COLORREF crRGB, WORD& wH, WORD& wL, WORD& wS); static COLORREF HLStoRGB(WORD wH, WORD wL, WORD wS); static WORD HueToRGB(WORD w1, WORD w2, WORD wH); static bool AppendFiles(const CString& sPath1, const CString& sPath2); static bool RenameFile(const CString& sPath1, const CString& sPath2); static bool RemoveFile(const CString& sPath); static bool RemoveTrailingSlash(CString& sPath); static void SaveWindowPlacement(const CWnd* pWnd, const CString& sPlacementKey, const CString& sPlacementSubKey); static void RestoreWindowPlacement(CWnd* pWnd, const CString& sPlacementKey, const CString& sPlacementSubKey, int nShowWindowCmd = -1); */ }; #endif // GENERICATLH_