CP_Main.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. // CP_Main.h : main header file for the CP_MAIN application
  2. //
  3. #if !defined(AFX_CP_MAIN_H__DAB2F753_2CC1_4FED_8095_763987961026__INCLUDED_)
  4. #define AFX_CP_MAIN_H__DAB2F753_2CC1_4FED_8095_763987961026__INCLUDED_
  5. #if _MSC_VER > 1000
  6. #pragma once
  7. #endif // _MSC_VER > 1000
  8. #ifndef __AFXWIN_H__
  9. #error include 'stdafx.h' before including this file for PCH
  10. #endif
  11. #include "resource.h" // main symbols
  12. #include "Clip.h"
  13. #include "DatabaseUtilities.h"
  14. #include "Misc.h"
  15. #include "Options.h"
  16. #include "ArrayEx.h"
  17. #include "MainFrm.h"
  18. #include "ProcessPaste.h"
  19. #include "MultiLanguage.h"
  20. #include "CopyThread.h"
  21. #include "ClipboardSaveRestore.h"
  22. #include "DittoCopyBuffer.h"
  23. #include "sqlite\CppSQLite3.h"
  24. //#define GET_APP ((CMainWnd*)theApp)
  25. extern class CCP_MainApp theApp;
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CCP_MainApp:
  28. // See CP_Main.cpp for the implementation of this class
  29. //
  30. class CCP_MainApp : public CWinApp
  31. {
  32. public:
  33. CCP_MainApp();
  34. ~CCP_MainApp();
  35. CppSQLite3DB m_db;
  36. HANDLE m_hMutex; // for singleton app
  37. // track stages of startup / shutdown
  38. bool m_bAppRunning;
  39. bool m_bAppExiting;
  40. bool m_bExitServerThread;
  41. // MainFrame
  42. HWND m_MainhWnd;
  43. CMainFrame* m_pMainFrame;
  44. void AfterMainCreate(); // called after main window creation
  45. void BeforeMainClose(); // called before main window close
  46. // System-wide HotKeys
  47. CHotKey* m_pDittoHotKey; // activate ditto's qpaste window
  48. CHotKey* m_pNamedPaste;
  49. CHotKey* m_pNamedCopy;
  50. CHotKey* m_pPosOne;
  51. CHotKey* m_pPosTwo;
  52. CHotKey* m_pPosThree;
  53. CHotKey* m_pPosFour;
  54. CHotKey* m_pPosFive;
  55. CHotKey* m_pPosSix;
  56. CHotKey* m_pPosSeven;
  57. CHotKey* m_pPosEight;
  58. CHotKey* m_pPosNine;
  59. CHotKey* m_pPosTen;
  60. CHotKey *m_pCopyBuffer1;
  61. CHotKey *m_pPasteBuffer1;
  62. CHotKey *m_pCutBuffer1;
  63. CHotKey *m_pCopyBuffer2;
  64. CHotKey *m_pPasteBuffer2;
  65. CHotKey *m_pCutBuffer2;
  66. CHotKey *m_pCopyBuffer3;
  67. CHotKey *m_pPasteBuffer3;
  68. CHotKey *m_pCutBuffer3;
  69. // Focus Tracking
  70. HWND m_hTargetWnd;
  71. bool TargetActiveWindow();
  72. bool ActivateTarget();
  73. bool ReleaseFocus(); // activate the target only if we are the active window
  74. CString GetTargetName();
  75. void SendPaste(bool bActivateTarget); // Activates the Target and sends Ctrl-V
  76. void SendCopy();
  77. void SendCut();
  78. // CopyThread and ClipViewer (Copy and Paste Management)
  79. CCopyThread m_CopyThread;
  80. void StartCopyThread();
  81. void StopCopyThread();
  82. // for posting messages
  83. HWND GetClipboardViewer() { return m_CopyThread.m_pClipboardViewer->m_hWnd; }
  84. // enables or disables copying the clipboard when it changes
  85. bool EnableCbCopy(bool bState) { return m_CopyThread.SetCopyOnChange(bState); }
  86. bool IsClipboardViewerConnected() { return m_CopyThread.IsClipboardViewerConnected(); }
  87. // user control over being in the clipboard viewer chain.
  88. bool GetConnectCV() { return m_CopyThread.GetConnectCV(); }
  89. void SetConnectCV(bool bConnect);
  90. bool ToggleConnectCV();
  91. void UpdateMenuConnectCV(CMenu* pMenu, UINT nMenuID);
  92. bool ImportClips(HWND hWnd);
  93. int ShowOptionsDlg();
  94. void OnDeleteID(long lID);
  95. BOOL GetClipData(long lID, CClipFormat &Clip);
  96. bool EditItems(CClipIDs &Ids, bool bShowError);
  97. // CClipList m_SaveClipQueue;
  98. // Retrieves all clips from CopyThread and Saves them.
  99. // returns the ID of the last Clip saved (or 0 if none)
  100. long SaveCopyClips();
  101. CClipTypes* LoadTypesFromDB(); // returns a "new" allocated object
  102. void ReloadTypes();
  103. void RefreshView(); // refreshes the view if it is visible
  104. void OnCopyCompleted( long lLastID, int count = 1 );
  105. void OnPasteCompleted();
  106. // Internal Clipboard for cut/copy/paste items between Groups
  107. bool m_IC_bCopy; // true to copy the items, false to move them
  108. CClipIDs m_IC_IDs; // buffer
  109. void IC_Cut(ARRAY* pIDs = NULL); // if NULL, this uses the current QPaste selection
  110. void IC_Copy(ARRAY* pIDs = NULL); // if NULL, this uses the current QPaste selection
  111. void IC_Paste();
  112. // Groups
  113. long m_GroupDefaultID; // new clips are saved to this group
  114. long m_GroupID; // current group
  115. long m_GroupParentID; // current group's parent
  116. CString m_GroupText; // current group's description
  117. BOOL EnterGroupID(long lID);
  118. long GetValidGroupID(); // returns a valid id (not negative)
  119. void SetGroupDefaultID(long lID); // sets a valid id
  120. // Window States
  121. // the ID given focus by CQPasteWnd::FillList
  122. long m_FocusID;
  123. bool m_bShowingQuickPaste;
  124. bool m_bRefreshView;
  125. CString m_Status;
  126. CQPasteWnd* QPasteWnd() { return m_pMainFrame->QuickPaste.m_pwndPaste; }
  127. void SetStatus(const TCHAR* status = NULL, bool bRepaintImmediately = false);
  128. void ShowPersistent(bool bVal);
  129. bool m_bRemoveOldEntriesPending;
  130. void Delayed_RemoveOldEntries(UINT delay);
  131. bool m_bAsynchronousRefreshView;
  132. //Socket Info
  133. SOCKET m_sSocket;
  134. void StartStopServerThread();
  135. void StopServerThread();
  136. long m_lClipsSent;
  137. long m_lClipsRecieved;
  138. long m_lLastGoodIndexForNextworkPassword;
  139. CLIPFORMAT m_cfIgnoreClipboard; // used by CClip::LoadFromClipboard
  140. CLIPFORMAT m_cfDelaySavingData;
  141. CLIPFORMAT m_PingFormat;
  142. CLIPFORMAT m_HTML_Format;
  143. CLIPFORMAT m_RemoteCF_HDROP;
  144. CLIPFORMAT m_RTFFormat;
  145. CLIPFORMAT m_DittoIdsFormat;
  146. COleDateTime m_oldtStartUp;
  147. //Mulitlange Support
  148. CMultiLanguage m_Language;
  149. enum eQuickPasteMode{NONE_QUICK_PASTE, ADDING_QUICK_PASTE, PASTING_QUICK_PASTE, DITTO_BUFFER_QUICK_PASTE};
  150. eQuickPasteMode m_QuickPasteMode;
  151. CClipList* m_pQuickPasteClip;
  152. bool m_bDittoHasFocus;
  153. CDittoCopyBuffer m_CopyBuffer;
  154. void PumpMessageEx();
  155. protected:
  156. // Overrides
  157. // ClassWizard generated virtual function overrides
  158. //{{AFX_VIRTUAL(CCP_MainApp)
  159. public:
  160. virtual BOOL InitInstance();
  161. virtual int ExitInstance();
  162. //}}AFX_VIRTUAL
  163. // Implementation
  164. //{{AFX_MSG(CCP_MainApp)
  165. afx_msg void OnAppAbout();
  166. // NOTE - the ClassWizard will add and remove member functions here.
  167. // DO NOT EDIT what you see in these blocks of generated code !
  168. //}}AFX_MSG
  169. DECLARE_MESSAGE_MAP()
  170. virtual BOOL OnIdle(LONG lCount);
  171. protected:
  172. void ShowCommandLineError(CString csTitle, CString csMessage);
  173. };
  174. /////////////////////////////////////////////////////////////////////////////
  175. //{{AFX_INSERT_LOCATION}}
  176. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  177. #endif // !defined(AFX_CP_MAIN_H__DAB2F753_2CC1_4FED_8095_763987961026__INCLUDED_)