Misc.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. #if !defined(AFX_CP_GUI_GLOBALS__FBCDED09_A6F2_47EB_873F_50A746EBC86B__INCLUDED_)
  2. #define AFX_CP_GUI_H__FBCDED09_A6F2_47EB_873F_50A746EBC86B__INCLUDED_
  3. #if _MSC_VER > 1000
  4. #pragma once
  5. #endif // _MSC_VER > 1000
  6. #include "ArrayEx.h"
  7. #define ONE_MINUTE 60000
  8. #define ONE_HOUR 3600000
  9. #define ONE_DAY 86400000
  10. #define DELETE_PTR(ptr) { if(ptr) {delete ptr; ptr = NULL;} }
  11. #define CATCH_SQLITE_EXCEPTION \
  12. catch (CppSQLite3Exception& e) \
  13. { \
  14. Log(StrF(_T("SQLITE Exception %d - %s"), e.errorCode(), e.errorMessage())); \
  15. ASSERT(FALSE); \
  16. } \
  17. #define CATCH_SQLITE_EXCEPTION_AND_RETURN(bRet) \
  18. catch (CppSQLite3Exception& e) \
  19. { \
  20. Log(StrF(_T("SQLITE Exception %d - %s"), e.errorCode(), e.errorMessage())); \
  21. ASSERT(FALSE); \
  22. return bRet; \
  23. } \
  24. #define FIX_PATH(strPath) \
  25. { \
  26. if (strPath[strlen(strPath)-1] != '\\' && strPath[strlen(strPath)-1] != '/') \
  27. strcat(strPath, "\\"); \
  28. }
  29. #define FIX_CSTRING_PATH(csPath) \
  30. { \
  31. if(csPath.IsEmpty() == FALSE && csPath.GetAt(csPath.GetLength()-1) != '\\' && csPath.GetAt(csPath.GetLength()-1) != '/') \
  32. csPath += "\\"; \
  33. }
  34. #include "DatabaseUtilities.h"
  35. CString GetIPAddress();
  36. CString GetComputerName();
  37. #define FUNC __FUNCTION__
  38. #define FUNCSIG __FUNCSIG__
  39. void AppendToFile(const TCHAR* fn, const TCHAR *msg);
  40. #define Log(msg) log(msg, false, __FILE__, __LINE__)
  41. void log(const TCHAR* msg, bool bFromSendRecieve = false, CString csFile = _T(""), long lLine = -1);
  42. CString GetErrorString(int err);
  43. #define LogSendRecieveInfo(cs) logsendrecieveinfo(cs, __FILE__, __LINE__)
  44. void logsendrecieveinfo(CString cs, CString csFile = _T(""), long lLine = -1);
  45. // Utility Functions
  46. CString StrF(const TCHAR * pszFormat, ...);
  47. // called after determining that the preceding character is a backslash
  48. BYTE GetEscapeChar( BYTE ch );
  49. CString RemoveEscapes( const TCHAR* str );
  50. CString GetWndText( HWND hWnd );
  51. // returns true if the given window is owned by this process
  52. bool IsAppWnd( HWND hWnd );
  53. // Global Memory Helper Functions
  54. BOOL IsValid( HGLOBAL hGlobal );
  55. void CopyToGlobalHP( HGLOBAL hDest, LPVOID pBuf, ULONG ulBufLen );
  56. void CopyToGlobalHH( HGLOBAL hDest, HGLOBAL hSource, ULONG ulBufLen );
  57. HGLOBAL NewGlobalP( LPVOID pBuf, UINT nLen );
  58. HGLOBAL NewGlobalH( HGLOBAL hSource, UINT nLen );
  59. HGLOBAL NewGlobal(UINT nLen);
  60. int CompareGlobalHP( HGLOBAL hLeft, LPVOID pBuf, ULONG ulBufLen );
  61. int CompareGlobalHH( HGLOBAL hLeft, HGLOBAL hRight, ULONG ulBufLen );
  62. BOOL EncryptString(CString &csString, UCHAR*& pOutput, int &nLenOutput);
  63. BOOL DecryptString(UCHAR *pData, int nLenIn, UCHAR*& pOutput, int &nLenOutput);
  64. int GetScreenWidth();
  65. int GetScreenHeight();
  66. void GetMonitorRect(int iMonitor, LPRECT lpDestRect);
  67. int GetMonitorFromRect(LPRECT lpMonitorRect);
  68. CLIPFORMAT GetFormatID(LPCTSTR cbName);
  69. CString GetFormatName(CLIPFORMAT cbType);
  70. BOOL PreTranslateGuiDll(MSG *pMsg);
  71. CString GetFilePath(CString csFullPath);
  72. CString GetFileName(CString csFileName);
  73. BOOL EnsureWindowVisible(CRect *pcrRect);
  74. __int64 GetLastWriteTime(const CString &csFile);
  75. CString GetProcessName(HWND hWnd);
  76. //Message to the main window to show icon or not
  77. #define WM_SHOW_TRAY_ICON WM_USER + 200
  78. #define WM_SETCONNECT WM_USER + 201
  79. #define WM_CV_IS_CONNECTED WM_USER + 202
  80. #define WM_CLOSE_APP WM_USER + 204
  81. #define WM_REFRESH_VIEW WM_USER + 205
  82. #define WM_CLIPBOARD_COPIED WM_USER + 206
  83. #define WM_ADD_TO_DATABASE_FROM_SOCKET WM_USER + 207
  84. #define WM_SEND_RECIEVE_ERROR WM_USER + 208
  85. #define WM_FOCUS_CHANGED WM_USER + 209
  86. #define WM_CV_GETCONNECT WM_USER + 211
  87. #define WM_EDIT_WND_CLOSING WM_USER + 212
  88. #define WM_SET_CONNECTED WM_USER + 213
  89. #define WM_LOAD_ClIP_ON_CLIPBOARD WM_USER + 214
  90. //defined in tray icon #define WM_CUSTOMIZE_TRAY_MENU WM_USER + 211
  91. #if !defined(_BITSET_)
  92. # include <bitset>
  93. #endif // !defined(_BITSET_)
  94. long NewGroupID(long lParentID = 0, CString text = "");
  95. BOOL DeleteAllIDs();
  96. BOOL DeleteFormats(long lDataID, ARRAY& formatIDs);
  97. __inline BOOL FileExists(LPCTSTR pszFile)
  98. {
  99. return (GetFileAttributes(pszFile) != 0xffffffff);
  100. }
  101. bool IsRunningLimited();
  102. BOOL IsVista();
  103. void DeleteReceivedFiles(CString csDir);
  104. #endif // !defined(AFX_CP_GUI_GLOBALS__FBCDED09_A6F2_47EB_873F_50A746EBC86B__INCLUDED_)