CP_Main.h 5.6 KB

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