CP_Main.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. // MainFrame
  39. HWND m_MainhWnd;
  40. CMainFrame* m_pMainFrame;
  41. void AfterMainCreate(); // called after main window creation
  42. void BeforeMainClose(); // called before main window close
  43. // System-wide HotKeys
  44. CHotKey* m_pDittoHotKey; // activate ditto's qpaste window
  45. CHotKey* m_pCopyHotKey; // named copy
  46. // Focus Tracking
  47. HWND m_hTargetWnd;
  48. // HWND m_hTargetFocus;
  49. bool TargetActiveWindow();
  50. bool ActivateTarget();
  51. bool ReleaseFocus(); // activate the target only if we are the active window
  52. CString GetTargetName() { return GetWndText( m_hTargetWnd ); }
  53. void SendPaste(); // Activates the Target and sends Ctrl-V
  54. CLIPFORMAT m_cfIgnoreClipboard; // used by CClip::LoadFromClipboard
  55. // CopyThread and ClipViewer (Copy and Paste Management)
  56. CCopyThread m_CopyThread;
  57. void StartCopyThread();
  58. void StopCopyThread();
  59. // for posting messages
  60. HWND GetClipboardViewer() { return m_CopyThread.m_pClipboardViewer->m_hWnd; }
  61. // enables or disables copying the clipboard when it changes
  62. bool EnableCbCopy(bool bState) { return m_CopyThread.SetCopyOnChange(bState); }
  63. bool IsClipboardViewerConnected() { return m_CopyThread.IsClipboardViewerConnected(); }
  64. // CClipList m_SaveClipQueue;
  65. // Retrieves all clips from CopyThread and Saves them.
  66. // returns the ID of the last Clip saved (or 0 if none)
  67. long SaveCopyClips();
  68. CClipTypes* LoadTypesFromDB(); // returns a "new" allocated object
  69. void ReloadTypes();
  70. void RefreshView(); // refreshes the view if it is visible
  71. void OnCopyCompleted( long lLastID, int count = 1 );
  72. void OnPasteCompleted();
  73. // Internal Clipboard for cut/copy/paste items between Groups
  74. bool m_IC_bCopy; // true to copy the items, false to move them
  75. CClipIDs m_IC_IDs; // buffer
  76. void IC_Cut( ARRAY* pIDs = NULL ); // if NULL, this uses the current QPaste selection
  77. void IC_Copy( ARRAY* pIDs = NULL ); // if NULL, this uses the current QPaste selection
  78. void IC_Paste();
  79. // Groups
  80. long m_GroupDefaultID; // new clips are saved to this group
  81. long m_GroupID; // current group
  82. long m_GroupParentID; // current group's parent
  83. CString m_GroupText; // current group's description
  84. BOOL EnterGroupID( long lID );
  85. long GetValidGroupID(); // returns a valid id (not negative)
  86. void SetGroupDefaultID( long lID ); // sets a valid id
  87. // Window States
  88. // the ID given focus by CQPasteWnd::FillList
  89. long m_FocusID; // -1 == keep previous position, 0 == go to latest ID
  90. bool m_bShowingOptions;
  91. bool m_bShowingQuickPaste;
  92. CString m_Status;
  93. CQPasteWnd* QPasteWnd() { return m_pMainFrame->QuickPaste.m_pwndPaste; }
  94. void SetStatus( const char* status = NULL, bool bRepaintImmediately = false );
  95. void ShowPersistent( bool bVal );
  96. bool m_bShowCopyProperties;
  97. void ShowCopyProperties( long lID );
  98. bool m_bRemoveOldEntriesPending;
  99. void Delayed_RemoveOldEntries( UINT delay );
  100. // Database
  101. CDaoDatabase* m_pDatabase;
  102. CDaoDatabase* EnsureOpenDB(CString csName = "");
  103. BOOL CloseDB();
  104. // Overrides
  105. // ClassWizard generated virtual function overrides
  106. //{{AFX_VIRTUAL(CCP_MainApp)
  107. public:
  108. virtual BOOL InitInstance();
  109. virtual int ExitInstance();
  110. //}}AFX_VIRTUAL
  111. // Implementation
  112. //{{AFX_MSG(CCP_MainApp)
  113. afx_msg void OnAppAbout();
  114. // NOTE - the ClassWizard will add and remove member functions here.
  115. // DO NOT EDIT what you see in these blocks of generated code !
  116. //}}AFX_MSG
  117. DECLARE_MESSAGE_MAP()
  118. virtual BOOL OnIdle(LONG lCount);
  119. };
  120. /////////////////////////////////////////////////////////////////////////////
  121. //{{AFX_INSERT_LOCATION}}
  122. // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
  123. #endif // !defined(AFX_CP_MAIN_H__DAB2F753_2CC1_4FED_8095_763987961026__INCLUDED_)