CP_Main.h 6.2 KB

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