| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120 | 
							- #if !defined(AFX_COPYTHREAD_H__C6766F04_0111_4314_986A_A0E02FF3B322__INCLUDED_)
 
- #define AFX_COPYTHREAD_H__C6766F04_0111_4314_986A_A0E02FF3B322__INCLUDED_
 
- #if _MSC_VER > 1000
 
- #pragma once
 
- #endif // _MSC_VER > 1000
 
- #include "ClipboardViewer.h"
 
- struct CCopyConfig
 
- {
 
- public:
 
- 	// WM_CLIPBOARD_COPIED is sent to this window when a copy is made.
 
- 	HWND        m_hClipHandler;
 
- 	// true to use PostMessage (asynchronous)
 
- 	// false to use SendMessage (synchronous)
 
- 	bool        m_bAsyncCopy;
 
- 	// true to create a copy of the clipboard contents when it changes
 
- 	// false to ignore changes in the clipboard
 
- 	bool        m_bCopyOnChange;
 
- 	// the supported types which are copied from the clipboard when it changes.
 
- 	CClipTypes* m_pSupportedTypes; // ONLY accessed from CopyThread
 
- 	CCopyConfig( HWND hClipHandler = NULL,
 
- 	             bool bAsyncCopy = false,
 
- 				 bool bCopyOnChange = false,
 
- 				 CClipTypes* pSupportedTypes = NULL )
 
- 	{
 
- 		m_hClipHandler = hClipHandler;
 
- 		m_bAsyncCopy = bAsyncCopy;
 
- 		m_bCopyOnChange = bCopyOnChange;
 
- 		m_pSupportedTypes = pSupportedTypes;
 
- 	}
 
- 	void DeleteTypes()
 
- 	{
 
- 		if( m_pSupportedTypes )
 
- 		{
 
- 			delete m_pSupportedTypes;
 
- 			m_pSupportedTypes = NULL;
 
- 		}
 
- 	}
 
- };
 
- class CCopyThread : public CWinThread
 
- {
 
- 	DECLARE_DYNCREATE(CCopyThread)
 
- public:
 
- 	CCopyThread();
 
- 	virtual ~CCopyThread();
 
- // Attributes
 
- public:
 
- // Operations
 
- public:
 
- 	bool m_bQuit;
 
- 	// critical section is held whenever shared data is changed 
 
- 	CRITICAL_SECTION		m_CS;
 
- 	void Hold()		{ ::EnterCriticalSection(&m_CS); }
 
- 	void Release()	{ ::LeaveCriticalSection(&m_CS); }
 
- // CopyThread Local (accessed from this CopyThread)
 
- 	// window owned by this thread which handles clipboard viewer messages
 
- 	CClipboardViewer*   m_pClipboardViewer; // permanent during lifetime of thread
 
- 	CCopyConfig         m_LocalConfig;
 
- 	// Called within Copy Thread:
 
- 	void OnClipboardChange(); // called by ClipboardViewer
 
- 	void SyncConfig(); // safely syncs m_LocalConfig with m_SharedConfig
 
- 	void AddToClips( CClip* pClip ); // after this, pClip is owned by m_pClips
 
- // Shared (use thread-safe access functions below)
 
- 	CCopyConfig         m_SharedConfig; 
 
- 	bool                m_bConfigChanged; // true if m_SharedConfig was changed.
 
- 	CClipList*          m_pClips; // snapshots of the clipboard when it changed.
 
- 	// Called within Main thread:
 
- 	bool IsClipboardViewerConnected();
 
- 	bool GetConnectCV();
 
- 	void SetConnectCV( bool bConnect );
 
- 	CClipList* GetClips(); // caller owns the returned CClipList
 
- 	void SetSupportedTypes( CClipTypes* pTypes ); // CopyThread will own pTypes
 
- 	HWND SetClipHandler( HWND hWnd ); // returns previous value
 
- 	HWND GetClipHandler();
 
- 	bool SetCopyOnChange( bool bVal ); // returns previous value
 
- 	bool GetCopyOnChange();
 
- 	bool SetAsyncCopy( bool bVal ); // returns previous value
 
- 	bool GetAsyncCopy();
 
- // Main thread
 
- 	void Init( CCopyConfig cfg );
 
- 	bool Quit();
 
- // Overrides
 
- 	// ClassWizard generated virtual function overrides
 
- 	//{{AFX_VIRTUAL(CCopyThread)
 
- 	public:
 
- 	virtual BOOL InitInstance();
 
- 	virtual int ExitInstance();
 
- 	//}}AFX_VIRTUAL
 
- 	// Generated message map functions
 
- 	//{{AFX_MSG(CCopyThread)
 
- 		// NOTE - the ClassWizard will add and remove member functions here.
 
- 	//}}AFX_MSG
 
- 	DECLARE_MESSAGE_MAP()
 
- };
 
- /////////////////////////////////////////////////////////////////////////////
 
- //{{AFX_INSERT_LOCATION}}
 
- // Microsoft Visual C++ will insert additional declarations immediately before the previous line.
 
- #endif // !defined(AFX_COPYTHREAD_H__C6766F04_0111_4314_986A_A0E02FF3B322__INCLUDED_)
 
 
  |