CP_Main.h 4.4 KB

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