Misc.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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 "Shared/ArrayEx.h"
  7. #define ONE_MINUTE 60000
  8. #define ONE_HOUR 3600000
  9. #define ONE_DAY 86400000
  10. #define CATCH_SQLITE_EXCEPTION \
  11. catch (CppSQLite3Exception& e) \
  12. { \
  13. Log(StrF(_T("SQLITE Exception %d - %s"), e.errorCode(), e.errorMessage())); \
  14. ASSERT(FALSE); \
  15. } \
  16. #define CATCH_SQLITE_EXCEPTION_AND_RETURN(bRet) \
  17. catch (CppSQLite3Exception& e) \
  18. { \
  19. Log(StrF(_T("SQLITE Exception %d - %s"), e.errorCode(), e.errorMessage())); \
  20. ASSERT(FALSE); \
  21. return bRet; \
  22. } \
  23. #define FIX_PATH(strPath) \
  24. { \
  25. if (strPath[strlen(strPath)-1] != '\\' && strPath[strlen(strPath)-1] != '/') \
  26. strcat(strPath, "\\"); \
  27. }
  28. #define FIX_CSTRING_PATH(csPath) \
  29. { \
  30. if(csPath.IsEmpty() == FALSE && csPath.GetAt(csPath.GetLength()-1) != '\\' && csPath.GetAt(csPath.GetLength()-1) != '/') \
  31. csPath += "\\"; \
  32. }
  33. #include "DatabaseUtilities.h"
  34. CString GetIPAddress();
  35. CString GetComputerName();
  36. #define FUNC __FUNCTION__
  37. #define FUNCSIG __FUNCSIG__
  38. void AppendToFile(const TCHAR* fn, const TCHAR *msg);
  39. #define Log(msg) log(msg, false, __FILE__, __LINE__)
  40. void log(const TCHAR* msg, bool bFromSendRecieve = false, CString csFile = _T(""), long lLine = -1);
  41. CString GetErrorString(int err);
  42. double IdleSeconds();
  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, SIZE_T ulBufLen);
  56. void CopyToGlobalHH(HGLOBAL hDest, HGLOBAL hSource, SIZE_T ulBufLen);
  57. HGLOBAL NewGlobalP(LPVOID pBuf, SIZE_T nLen);
  58. HGLOBAL NewGlobalH(HGLOBAL hSource, SIZE_T nLen);
  59. HGLOBAL NewGlobal(SIZE_T nLen);
  60. int CompareGlobalHP(HGLOBAL hLeft, LPVOID pBuf, SIZE_T ulBufLen);
  61. int CompareGlobalHH(HGLOBAL hLeft, HGLOBAL hRight, SIZE_T 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 + 215
  91. //defined in tray icon #define WM_TRAY_MENU_MOUSE_MOVE WM_USER + 216
  92. #define WM_RELOAD_CLIP_ORDER WM_USER + 217
  93. #define WM_GLOBAL_CLIPS_CLOSED WM_USER + 218
  94. #define WM_OPTIONS_CLOSED WM_USER + 219
  95. #define WM_SHOW_OPTIONS WM_USER + 220
  96. #if !defined(_BITSET_)
  97. # include <bitset>
  98. #endif // !defined(_BITSET_)
  99. long NewGroupID(int parentID = 0, CString text = "");
  100. BOOL DeleteAllIDs();
  101. BOOL DeleteFormats(int parentID, ARRAY& formatIDs);
  102. __inline BOOL FileExists(LPCTSTR pszFile)
  103. {
  104. return (GetFileAttributes(pszFile) != 0xffffffff);
  105. }
  106. bool IsRunningLimited();
  107. BOOL IsVista();
  108. void DeleteReceivedFiles(CString csDir);
  109. #endif // !defined(AFX_CP_GUI_GLOBALS__FBCDED09_A6F2_47EB_873F_50A746EBC86B__INCLUDED_)