CP_Main.h 6.1 KB

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