Clip.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. // ProcessCopy.h: classes for saving the clipboard to db
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #if !defined(AFX_PROCESSCOPY_H__185CBB6F_4B63_4397_8FF9_E18D777DA506__INCLUDED_)
  5. #define AFX_PROCESSCOPY_H__185CBB6F_4B63_4397_8FF9_E18D777DA506__INCLUDED_
  6. #if _MSC_VER > 1000
  7. #pragma once
  8. #endif // _MSC_VER > 1000
  9. #include <afxole.h>
  10. #include <afxtempl.h>
  11. class CClip;
  12. class CCopyThread;
  13. typedef CArray<CLIPFORMAT, CLIPFORMAT> CClipTypes;
  14. /*----------------------------------------------------------------------------*\
  15. COleDataObjectEx
  16. \*----------------------------------------------------------------------------*/
  17. class COleDataObjectEx : public COleDataObject
  18. {
  19. public:
  20. // creates global from IStream if necessary
  21. HGLOBAL GetGlobalData(CLIPFORMAT cfFormat, LPFORMATETC lpFormatEtc = NULL);
  22. };
  23. /*----------------------------------------------------------------------------*\
  24. CClipFormat - holds the data of one clip format.
  25. \*----------------------------------------------------------------------------*/
  26. class CClipFormat
  27. {
  28. public:
  29. CLIPFORMAT m_cfType;
  30. HGLOBAL m_hgData;
  31. bool bDeleteData;
  32. CClipFormat(CLIPFORMAT cfType = 0, HGLOBAL hgData = 0);
  33. ~CClipFormat();
  34. void Clear();
  35. void Free();
  36. };
  37. /*----------------------------------------------------------------------------*\
  38. CClipFormats - holds an array of CClipFormat
  39. \*----------------------------------------------------------------------------*/
  40. class CClipFormats : public CArray<CClipFormat,CClipFormat&>
  41. {
  42. public:
  43. // returns a pointer to the CClipFormat in this array which matches the given type
  44. // or NULL if that type doesn't exist in this array.
  45. CClipFormat* FindFormat(UINT cfType);
  46. };
  47. /*----------------------------------------------------------------------------*\
  48. CClip - holds multiple CClipFormats and clip statistics
  49. - provides static functions for manipulating a Clip as a single unit.
  50. \*----------------------------------------------------------------------------*/
  51. class CClip
  52. {
  53. public:
  54. long m_ID;
  55. CClipFormats m_Formats;
  56. const CClip& operator=(const CClip &clip);
  57. // statistics assigned by LoadFromClipboard
  58. CTime m_Time; // time copied from clipboard
  59. CString m_Desc;
  60. ULONG m_lTotalCopySize;
  61. long m_lParent;
  62. long m_lDontAutoDelete;
  63. long m_lShortCut;
  64. BOOL m_bIsGroup;
  65. DWORD m_CRC;
  66. CString m_csQuickPaste;
  67. static DWORD m_LastAddedCRC;
  68. static long m_LastAddedID;
  69. CClip();
  70. ~CClip();
  71. void Clear();
  72. void EmptyFormats();
  73. bool AddFormat(CLIPFORMAT cfType, void* pData, UINT nLen);
  74. bool LoadFromClipboard(CClipTypes* pClipTypes);
  75. bool AddToDB(bool bCheckForDuplicates = true);
  76. void MakeLatestTime();
  77. BOOL LoadMainTable(long lID);
  78. DWORD GenerateCRC();
  79. // Allocates a Global containing the requested Clip's Format Data
  80. static HGLOBAL LoadFormat(long lID, UINT cfType);
  81. // Fills "formats" with the Data of all Formats in the db for the given Clip ID
  82. bool LoadFormats(long lID, bool bOnlyLoad_CF_TEXT = false);
  83. // Fills "types" with all Types in the db for the given Clip ID
  84. static void LoadTypes(long lID, CClipTypes& types);
  85. protected:
  86. bool AddToMainTable();
  87. bool AddToDataTable();
  88. };
  89. /*----------------------------------------------------------------------------*\
  90. CClipList
  91. \*----------------------------------------------------------------------------*/
  92. class CClipList : public CList<CClip*,CClip*>
  93. {
  94. public:
  95. ~CClipList();
  96. // returns the number of clips actually saved
  97. // while this does empty the Format Data, it does not delete the Clips.
  98. int AddToDB( bool bLatestTime = false, bool bShowStatus = true );
  99. const CClipList& operator=(const CClipList &cliplist);
  100. };
  101. #endif // !defined(AFX_PROCESSCOPY_H__185CBB6F_4B63_4397_8FF9_E18D777DA506__INCLUDED_)