CP_Main.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. #pragma once
  2. #ifndef __AFXWIN_H__
  3. #error include 'stdafx.h' before including this file for PCH
  4. #endif
  5. #include "resource.h" // main symbols
  6. #include "Clip.h"
  7. #include "DatabaseUtilities.h"
  8. #include "Misc.h"
  9. #include "Options.h"
  10. #include "Shared/ArrayEx.h"
  11. #include "MainFrm.h"
  12. #include "ProcessPaste.h"
  13. #include "MultiLanguage.h"
  14. #include "CopyThread.h"
  15. #include "ClipboardSaveRestore.h"
  16. #include "DittoCopyBuffer.h"
  17. #include "sqlite\CppSQLite3.h"
  18. #include "DittoAddins.h"
  19. #include "externalwindowtracker.h"
  20. #include "HotKeys.h"
  21. #include "DPI.h"
  22. extern class CCP_MainApp theApp;
  23. class CCP_MainApp : public CWinApp
  24. {
  25. public:
  26. CCP_MainApp();
  27. ~CCP_MainApp();
  28. CppSQLite3DB m_db;
  29. HANDLE m_hMutex; // for singleton app
  30. // track stages of startup / shutdown
  31. bool m_bAppRunning;
  32. bool m_bAppExiting;
  33. int m_connectOnStartup;
  34. bool m_bExitServerThread;
  35. // MainFrame
  36. HWND m_MainhWnd;
  37. CMainFrame* m_pMainFrame;
  38. void AfterMainCreate(); // called after main window creation
  39. void BeforeMainClose(); // called before main window close
  40. // System-wide HotKeys
  41. CHotKey* m_pDittoHotKey; // activate ditto's qpaste window
  42. CHotKey* m_pPosOne;
  43. CHotKey* m_pPosTwo;
  44. CHotKey* m_pPosThree;
  45. CHotKey* m_pPosFour;
  46. CHotKey* m_pPosFive;
  47. CHotKey* m_pPosSix;
  48. CHotKey* m_pPosSeven;
  49. CHotKey* m_pPosEight;
  50. CHotKey* m_pPosNine;
  51. CHotKey* m_pPosTen;
  52. CHotKey *m_pCopyBuffer1;
  53. CHotKey *m_pPasteBuffer1;
  54. CHotKey *m_pCutBuffer1;
  55. CHotKey *m_pCopyBuffer2;
  56. CHotKey *m_pPasteBuffer2;
  57. CHotKey *m_pCutBuffer2;
  58. CHotKey *m_pCopyBuffer3;
  59. CHotKey *m_pPasteBuffer3;
  60. CHotKey *m_pCutBuffer3;
  61. CHotKey *m_pTextOnlyPaste;
  62. ExternalWindowTracker m_activeWnd;
  63. // CopyThread and ClipViewer (Copy and Paste Management)
  64. CCopyThread m_CopyThread;
  65. void StartCopyThread();
  66. void StopCopyThread();
  67. // for posting messages
  68. HWND GetClipboardViewer() { return m_CopyThread.m_pClipboardViewer->m_hWnd; }
  69. bool EnableCbCopy(bool bState) { return m_CopyThread.SetCopyOnChange(bState); }
  70. bool IsClipboardViewerConnected() { return m_CopyThread.IsClipboardViewerConnected(); }
  71. bool GetConnectCV() { return m_CopyThread.GetConnectCV(); }
  72. void SetConnectCV(bool bConnect);
  73. bool ToggleConnectCV();
  74. void UpdateMenuConnectCV(CMenu* pMenu, UINT nMenuID);
  75. bool ImportClips(HWND hWnd);
  76. void LoadGlobalClips();
  77. void OnDeleteID(long lID);
  78. BOOL GetClipData(long lID, CClipFormat &Clip);
  79. bool EditItems(CClipIDs &Ids, bool bShowError);
  80. CClipTypes* LoadTypesFromDB(); // returns a "new" allocated object
  81. void ReloadTypes();
  82. void RefreshView(); // refreshes the view if it is visible
  83. void RefreshClipOrder(int clipId);
  84. void OnCopyCompleted( long lLastID, int count = 1 );
  85. void OnPasteCompleted();
  86. // Internal Clipboard for cut/copy/paste items between Groups
  87. bool m_IC_bCopy; // true to copy the items, false to move them
  88. CClipIDs m_IC_IDs; // buffer
  89. void IC_Cut(ARRAY* pIDs = NULL); // if NULL, this uses the current QPaste selection
  90. void IC_Copy(ARRAY* pIDs = NULL); // if NULL, this uses the current QPaste selection
  91. void IC_Paste();
  92. // Groups
  93. long m_GroupDefaultID; // new clips are saved to this group
  94. long m_GroupID; // current group
  95. long m_GroupParentID; // current group's parent
  96. CString m_GroupText; // current group's description
  97. BOOL EnterGroupID(long lID);
  98. long GetValidGroupID(); // returns a valid id (not negative)
  99. void SetGroupDefaultID(long lID); // sets a valid id
  100. // Window States
  101. // the ID given focus by CQPasteWnd::FillList
  102. long m_FocusID;
  103. bool m_bShowingQuickPaste;
  104. bool m_bRefreshView;
  105. CString m_Status;
  106. CQPasteWnd* QPasteWnd();
  107. HWND QPastehWnd();
  108. void SetStatus(const TCHAR* status = NULL, bool bRepaintImmediately = false);
  109. void ShowPersistent(bool bVal);
  110. bool m_bAsynchronousRefreshView;
  111. //Socket Info
  112. SOCKET m_sSocket;
  113. void StartStopServerThread();
  114. void StopServerThread();
  115. long m_lClipsSent;
  116. long m_lClipsRecieved;
  117. long m_lLastGoodIndexForNextworkPassword;
  118. CLIPFORMAT m_cfIgnoreClipboard; // used by CClip::LoadFromClipboard
  119. CLIPFORMAT m_cfDelaySavingData;
  120. CLIPFORMAT m_PingFormat;
  121. CLIPFORMAT m_HTML_Format;
  122. CLIPFORMAT m_RemoteCF_HDROP;
  123. CLIPFORMAT m_RTFFormat;
  124. COleDateTime m_oldtStartUp;
  125. CMultiLanguage m_Language;
  126. CDittoCopyBuffer m_CopyBuffer;
  127. void PumpMessageEx(HWND hWnd = NULL);
  128. CDittoAddins m_Addins;
  129. CDPI m_metrics;
  130. ULONG_PTR m_gdiplusToken;
  131. public:
  132. virtual BOOL InitInstance();
  133. virtual int ExitInstance();
  134. afx_msg void OnAppAbout();
  135. DECLARE_MESSAGE_MAP()
  136. virtual BOOL OnIdle(LONG lCount);
  137. protected:
  138. void ShowCommandLineError(CString csTitle, CString csMessage);
  139. };