CP_Main.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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 "ProcessCopy.h"
  13. #include "DatabaseUtilities.h"
  14. #include "Misc.h"
  15. #include "DataTable.h"
  16. #include "MainTable.h"
  17. #include "TypesTable.h"
  18. #include "ArrayEx.h"
  19. #include "MainFrm.h"
  20. #include "ProcessPaste.h"
  21. #define MAIN_WND_TITLE "Ditto MainWnd"
  22. //#define GET_APP ((CCP_MainApp *)AfxGetApp())
  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. HANDLE m_hMutex; // for singleton app
  35. // track stages of startup / shutdown
  36. bool m_bAppRunning;
  37. bool m_bAppExiting;
  38. bool m_bExitServerThread;
  39. // MainFrame
  40. HWND m_MainhWnd;
  41. CMainFrame* m_pMainFrame;
  42. void AfterMainCreate(); // called after main window creation
  43. void BeforeMainClose(); // called before main window close
  44. // System-wide HotKeys
  45. CHotKey* m_pDittoHotKey; // activate ditto's qpaste window
  46. CHotKey* m_pCopyHotKey; // named copy
  47. CHotKey* m_pPosOne;
  48. CHotKey* m_pPosTwo;
  49. CHotKey* m_pPosThree;
  50. CHotKey* m_pPosFour;
  51. CHotKey* m_pPosFive;
  52. CHotKey* m_pPosSix;
  53. CHotKey* m_pPosSeven;
  54. CHotKey* m_pPosEight;
  55. CHotKey* m_pPosNine;
  56. CHotKey* m_pPosTen;
  57. // Focus Tracking
  58. HWND m_hTargetWnd;
  59. // HWND m_hTargetFocus;
  60. bool TargetActiveWindow();
  61. bool ActivateTarget();
  62. bool ReleaseFocus(); // activate the target only if we are the active window
  63. CString GetTargetName();
  64. void SendPaste(bool bActivateTarget); // Activates the Target and sends Ctrl-V
  65. CLIPFORMAT m_cfIgnoreClipboard; // used by CClip::LoadFromClipboard
  66. // CopyThread and ClipViewer (Copy and Paste Management)
  67. CCopyThread m_CopyThread;
  68. void StartCopyThread();
  69. void StopCopyThread();
  70. // for posting messages
  71. HWND GetClipboardViewer() { return m_CopyThread.m_pClipboardViewer->m_hWnd; }
  72. // enables or disables copying the clipboard when it changes
  73. bool EnableCbCopy(bool bState) { return m_CopyThread.SetCopyOnChange(bState); }
  74. bool IsClipboardViewerConnected() { return m_CopyThread.IsClipboardViewerConnected(); }
  75. // user control over being in the clipboard viewer chain.
  76. bool GetConnectCV() { return m_CopyThread.GetConnectCV(); }
  77. void SetConnectCV( bool bConnect );
  78. bool ToggleConnectCV();
  79. void UpdateMenuConnectCV( CMenu* pMenu, UINT nMenuID );
  80. // CClipList m_SaveClipQueue;
  81. // Retrieves all clips from CopyThread and Saves them.
  82. // returns the ID of the last Clip saved (or 0 if none)
  83. long SaveCopyClips();
  84. CClipTypes* LoadTypesFromDB(); // returns a "new" allocated object
  85. void ReloadTypes();
  86. void RefreshView(); // refreshes the view if it is visible
  87. void OnCopyCompleted( long lLastID, int count = 1 );
  88. void OnPasteCompleted();
  89. // Internal Clipboard for cut/copy/paste items between Groups
  90. bool m_IC_bCopy; // true to copy the items, false to move them
  91. CClipIDs m_IC_IDs; // buffer
  92. void IC_Cut( ARRAY* pIDs = NULL ); // if NULL, this uses the current QPaste selection
  93. void IC_Copy( ARRAY* pIDs = NULL ); // if NULL, this uses the current QPaste selection
  94. void IC_Paste();
  95. // Groups
  96. long m_GroupDefaultID; // new clips are saved to this group
  97. long m_GroupID; // current group
  98. long m_GroupParentID; // current group's parent
  99. CString m_GroupText; // current group's description
  100. BOOL EnterGroupID( long lID );
  101. long GetValidGroupID(); // returns a valid id (not negative)
  102. void SetGroupDefaultID( long lID ); // sets a valid id
  103. // Window States
  104. // the ID given focus by CQPasteWnd::FillList
  105. long m_FocusID; // -1 == keep previous position, 0 == go to latest ID
  106. bool m_bShowingOptions;
  107. bool m_bShowingQuickPaste;
  108. CString m_Status;
  109. CQPasteWnd* QPasteWnd() { return m_pMainFrame->QuickPaste.m_pwndPaste; }
  110. void SetStatus( const char* status = NULL, bool bRepaintImmediately = false );
  111. void ShowPersistent( bool bVal );
  112. bool m_bShowCopyProperties;
  113. void ShowCopyProperties( long lID );
  114. bool m_bRemoveOldEntriesPending;
  115. void Delayed_RemoveOldEntries( UINT delay );
  116. // Database
  117. CDaoDatabase* m_pDatabase;
  118. CDaoDatabase* EnsureOpenDB(CString csName = "");
  119. BOOL CloseDB();
  120. bool m_bAsynchronousRefreshView;
  121. //Socket Info
  122. SOCKET m_sSocket;
  123. CRITICAL_SECTION m_CriticalSection;
  124. CPopup *m_pcpSendRecieveError;
  125. void StartStopServerThread();
  126. long m_lClipsSent;
  127. long m_lClipsRecieved;
  128. COleDateTime m_oldtStartUp;
  129. // Overrides
  130. // ClassWizard generated virtual function overrides
  131. //{{AFX_VIRTUAL(CCP_MainApp)
  132. public:
  133. virtual BOOL InitInstance();
  134. virtual int ExitInstance();
  135. //}}AFX_VIRTUAL
  136. // Implementation
  137. //{{AFX_MSG(CCP_MainApp)
  138. afx_msg void OnAppAbout();
  139. // NOTE - the ClassWizard will add and remove member functions here.
  140. // DO NOT EDIT what you see in these blocks of generated code !
  141. //}}AFX_MSG
  142. DECLARE_MESSAGE_MAP()
  143. virtual BOOL OnIdle(LONG lCount);
  144. };
  145. /////////////////////////////////////////////////////////////////////////////
  146. //{{AFX_INSERT_LOCATION}}
  147. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  148. #endif // !defined(AFX_CP_MAIN_H__DAB2F753_2CC1_4FED_8095_763987961026__INCLUDED_)