Misc.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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 INVALID_STICKY -(2147483647)
  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. double IdleSeconds();
  44. #define LogSendRecieveInfo(cs) logsendrecieveinfo(cs, __FILE__, __LINE__)
  45. void logsendrecieveinfo(CString cs, CString csFile = _T(""), long lLine = -1);
  46. // Utility Functions
  47. CString StrF(const TCHAR * pszFormat, ...);
  48. // called after determining that the preceding character is a backslash
  49. BYTE GetEscapeChar( BYTE ch );
  50. CString RemoveEscapes( const TCHAR* str );
  51. CString GetWndText( HWND hWnd );
  52. // returns true if the given window is owned by this process
  53. bool IsAppWnd( HWND hWnd );
  54. // Global Memory Helper Functions
  55. BOOL IsValid(HGLOBAL hGlobal);
  56. void CopyToGlobalHP(HGLOBAL hDest, LPVOID pBuf, SIZE_T ulBufLen);
  57. void CopyToGlobalHH(HGLOBAL hDest, HGLOBAL hSource, SIZE_T ulBufLen);
  58. HGLOBAL NewGlobalP(LPVOID pBuf, SIZE_T nLen);
  59. HGLOBAL NewGlobalH(HGLOBAL hSource, SIZE_T nLen);
  60. HGLOBAL NewGlobal(SIZE_T nLen);
  61. int CompareGlobalHP(HGLOBAL hLeft, LPVOID pBuf, SIZE_T ulBufLen);
  62. int CompareGlobalHH(HGLOBAL hLeft, HGLOBAL hRight, SIZE_T ulBufLen);
  63. BOOL EncryptString(CString &csString, UCHAR*& pOutput, int &nLenOutput);
  64. BOOL DecryptString(UCHAR *pData, int nLenIn, UCHAR*& pOutput, int &nLenOutput);
  65. int GetScreenWidth();
  66. int GetScreenHeight();
  67. void GetMonitorRect(int iMonitor, LPRECT lpDestRect);
  68. int GetMonitorFromRect(LPRECT lpMonitorRect);
  69. CLIPFORMAT GetFormatID(LPCTSTR cbName);
  70. CString GetFormatName(CLIPFORMAT cbType);
  71. BOOL PreTranslateGuiDll(MSG *pMsg);
  72. CString GetFilePath(CString csFullPath);
  73. CString GetFileName(CString csFileName);
  74. BOOL EnsureWindowVisible(CRect *pcrRect);
  75. CRect CenterRect(CRect startingRect);
  76. CRect CenterRectFromRect(CRect startingRect, CRect outerRect);
  77. __int64 GetLastWriteTime(const CString &csFile);
  78. CString GetProcessName(HWND hWnd);
  79. //Message to the main window to show icon or not
  80. #define WM_SHOW_TRAY_ICON WM_USER + 200
  81. #define WM_SETCONNECT WM_USER + 201
  82. #define WM_CV_IS_CONNECTED WM_USER + 202
  83. #define WM_CLOSE_APP WM_USER + 204
  84. #define WM_REFRESH_VIEW WM_USER + 205
  85. #define WM_CLIPBOARD_COPIED WM_USER + 206
  86. #define WM_ADD_TO_DATABASE_FROM_SOCKET WM_USER + 207
  87. #define WM_SEND_RECIEVE_ERROR WM_USER + 208
  88. #define WM_FOCUS_CHANGED WM_USER + 209
  89. #define WM_CV_GETCONNECT WM_USER + 211
  90. #define WM_EDIT_WND_CLOSING WM_USER + 212
  91. #define WM_SET_CONNECTED WM_USER + 213
  92. #define WM_LOAD_ClIP_ON_CLIPBOARD WM_USER + 214
  93. //defined in tray icon #define WM_CUSTOMIZE_TRAY_MENU WM_USER + 215
  94. //defined in tray icon #define WM_TRAY_MENU_MOUSE_MOVE WM_USER + 216
  95. #define WM_RELOAD_CLIP_ORDER WM_USER + 217
  96. #define WM_GLOBAL_CLIPS_CLOSED WM_USER + 218
  97. #define WM_OPTIONS_CLOSED WM_USER + 219
  98. #define WM_SHOW_OPTIONS WM_USER + 220
  99. #define WM_DELETE_CLIPS_CLOSED WM_USER + 221
  100. #define WM_OPEN_CLOSE_WINDWOW WM_USER + 222
  101. #if !defined(_BITSET_)
  102. # include <bitset>
  103. #endif // !defined(_BITSET_)
  104. long NewGroupID(int parentID = 0, CString text = "");
  105. BOOL DeleteAllIDs();
  106. BOOL DeleteFormats(int parentID, ARRAY& formatIDs);
  107. __inline BOOL FileExists(LPCTSTR pszFile)
  108. {
  109. return (GetFileAttributes(pszFile) != 0xffffffff);
  110. }
  111. bool IsRunningLimited();
  112. BOOL IsVista();
  113. void DeleteReceivedFiles(CString csDir);
  114. __int64 FileSize(const TCHAR *fileName);
  115. int FindNoCaseAndInsert(CString& mainStr, CString& findStr, CString preInsert, CString postInsert);
  116. void OnInitMenuPopupEx(CMenu *pPopupMenu, UINT nIndex, BOOL bSysMenu, CWnd *pWnd);
  117. CString InternetEncode(CString text);
  118. bool WriteCF_DIBToFile(CString csPath, LPVOID data, ULONG size);
  119. #endif // !defined(AFX_CP_GUI_GLOBALS__FBCDED09_A6F2_47EB_873F_50A746EBC86B__INCLUDED_)