📄 afxole.h
字号:
DWORD nOpenFlags = modeReadWrite|shareExclusive|modeCreate,
CFileException* pError = NULL);
BOOL CreateMemoryStream(CFileException* pError = NULL);
// attach & detach can be used when Open/Create functions aren't adequate
void Attach(LPSTREAM lpStream);
LPSTREAM Detach();
IStream* GetStream() const;
// Returns the current stream
// Implementation
public:
LPSTREAM m_lpStream;
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
virtual ~COleStreamFile();
// attributes for implementation
BOOL GetStatus(CFileStatus& rStatus) const;
virtual DWORD GetPosition() const;
virtual const CString GetStorageName() const;
// overrides for implementation
virtual CFile* Duplicate() const;
virtual LONG Seek(LONG lOff, UINT nFrom);
virtual void SetLength(DWORD dwNewLen);
virtual DWORD GetLength() const;
virtual UINT Read(void* lpBuf, UINT nCount);
virtual void Write(const void* lpBuf, UINT nCount);
virtual void LockRange(DWORD dwPos, DWORD dwCount);
virtual void UnlockRange(DWORD dwPos, DWORD dwCount);
virtual void Abort();
virtual void Flush();
virtual void Close();
protected:
CString m_strStorageName;
};
/////////////////////////////////////////////////////////////////////////////
// CMonikerFile - implementation of COleStreamFile that uses an IMoniker to
// get the IStream
class CMonikerFile: public COleStreamFile
{
DECLARE_DYNAMIC(CMonikerFile)
public:
CMonikerFile();
virtual BOOL Open(LPCTSTR lpszURL, CFileException* pError=NULL);
// Uses synchronous URLMonikers to create a moniker.
// Opens the URL specified.
// If provided, pError will be set in case of error.
// Return value: TRUE if successful, FALSE otherwise.
virtual BOOL Open(IMoniker* pMoniker, CFileException* pError=NULL);
// Binds to the provided moniker to obtain a stream.
// If provided, pError will be set in case of error.
// Return value: TRUE if successful, FALSE otherwise.
virtual void Close();
// Detaches the stream, Release()s it, and the moniker. Close may be
// called on unopened, or already closed streams.
BOOL Detach(CFileException* pError = NULL);
// Closes the stream. If there is an error when closing, then the
// error code will be placed in pError and the function will return FALSE.
IMoniker* GetMoniker() const;
// Returns the current moniker. The moniker returned is not AddRef()'ed.
protected:
// Overidables
IBindCtx* CreateBindContext(CFileException* pError);
// A hook so users can provide a particular IBindCtx, potentially one
// on which the user has registered one or more objects.
// Implementation
protected:
virtual BOOL Open(LPCTSTR lpszUrl, IBindHost* pBindHost,
IBindStatusCallback* pBSC, IBindCtx* pBindCtx, CFileException* pError);
BOOL Attach(LPCTSTR lpszUrl, IBindHost* pBindHost,
IBindStatusCallback* pBSC, IBindCtx* pBindCtx, CFileException* pError);
virtual BOOL Open(IMoniker* pMoniker, IBindHost* pBindHost,
IBindStatusCallback* pBSC, IBindCtx* pBindCtx, CFileException* pError);
BOOL Attach(IMoniker* pMoniker, IBindHost* pBindHost,
IBindStatusCallback* pBSC, IBindCtx* pBindCtx, CFileException* pError);
virtual BOOL PostBindToStream(CFileException* pError);
static IBindHost* CreateBindHost();
public:
virtual ~CMonikerFile();
// Closes the stream, and releases the moniker if needed.
virtual void Flush();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
// Calls COleStreamFile::Dump(), and prints out moniker value.
#endif
protected:
IPTR(IMoniker) m_Moniker;
// The moniker provided or created to which this class is bound.
CMonikerFile(const CMonikerFile&);
// Prevents copying.
};
/////////////////////////////////////////////////////////////////////////////
// CAsyncMonikerFile - implementation of COleStreamFile that uses an
// asynchronous IMoniker to get the IStream
class _AfxBindStatusCallback; // Forward declaration
class CAsyncMonikerFile: public CMonikerFile
{
DECLARE_DYNAMIC(CAsyncMonikerFile)
public:
CAsyncMonikerFile();
// Creates the IBindStatusCallback used internally to provide asynchronous
// operation.
//All Open overloads call one of these two.
virtual BOOL Open(LPCTSTR lpszURL, IBindHost* pBindHost,
CFileException* pError=NULL);
virtual BOOL Open(IMoniker* pMoniker, IBindHost* pBindHost,
CFileException* pError=NULL);
//Open overloads that take monikers
virtual BOOL Open(IMoniker* pMoniker, CFileException* pError=NULL);
virtual BOOL Open(IMoniker* pMoniker, IServiceProvider* pServiceProvider,
CFileException* pError=NULL);
virtual BOOL Open(IMoniker* pMoniker, IUnknown* pUnknown,
CFileException* pError=NULL);
//Open overloads that take strings
virtual BOOL Open(LPCTSTR lpszURL, CFileException* pError=NULL);
virtual BOOL Open(LPCTSTR lpszURL, IServiceProvider* pServiceProvider,
CFileException* pError=NULL);
virtual BOOL Open(LPCTSTR lpszURL, IUnknown* pUnknown,
CFileException* pError=NULL);
virtual void Close();
IBinding* GetBinding() const;
// Returns the binding provided when the asychronous transfer begins.
// With the IBinding*, the user may abort, or pause the transfer.
// NULL may be returned if for any reason the transfer could not be
// made asynchronous, or if the IBinding* has not yet been provided by
// the system.
FORMATETC* GetFormatEtc() const;
// Returns the FORMATETC for the currently opened stream. NULL will be
// returned if this is called from outside the context of OnDataAvailable.
// If you want to keep the FORMATETC beyond this call, make a copy of it.
// The FORMATETC indicates the format of the data in the stream.
protected:
// Overidables
virtual IUnknown* CreateBindStatusCallback(IUnknown* pUnkControlling);
virtual DWORD GetBindInfo() const;
// Returns the settings returned by IBindStatusCallback::GetBindInfo.
// The default values returned should work for most cases and should not
// be changed lightly.
virtual LONG GetPriority() const;
// Returns the priority at which the asynchronous transfer will take
// place. The value is one of the standard thread priority flags.
// By default THREAD_PRIORITY_NORMAL is returned.
virtual void OnDataAvailable(DWORD dwSize, DWORD bscfFlag);
// Called when there is data available to be read. dwSize indicates
// the cumulative number of bytes which can be read. The bscfFlag may be used
// to identify first, last, and intermediate blocks of data.
virtual void OnLowResource();
// This is called when resources are low.
virtual void OnStartBinding();
// Called when the binding is starting up.
virtual void OnProgress(ULONG ulProgress, ULONG ulProgressMax,
ULONG ulStatusCode, LPCTSTR szStatusText);
virtual void OnStopBinding(HRESULT hresult, LPCTSTR szError);
// Called when the transfer is stopped. This function releases the
// IBinding and should nearly always be call when overidden.
// Implementation
public:
virtual ~CAsyncMonikerFile();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
// Calls CMonikerFile::Dump(), and prints out IBinding,
// IBindStatusCallback, and m_pFormatEtc values.
#endif
virtual UINT Read(void* lpBuf, UINT nCount);
protected:
friend class _AfxBindStatusCallback;
_AfxBindStatusCallback* m_pAfxBSCCurrent;
BOOL m_bStopBindingReceived;
void EndCallbacks();
IPTR(IBinding) m_Binding;
FORMATETC* m_pFormatEtc;
void SetBinding(IBinding* pBinding);
// Sets and AddRefs m_Binding
void SetFormatEtc(FORMATETC* pFormatEtc);
// Sets the FORMATETC for the current stream.
virtual BOOL PostBindToStream(CFileException* pError);
};
/////////////////////////////////////////////////////////////////////////////
// COleDropSource (advanced drop source support)
class COleDropSource : public CCmdTarget
{
// Constructors
public:
COleDropSource();
// Overridables
virtual SCODE QueryContinueDrag(BOOL bEscapePressed, DWORD dwKeyState);
virtual SCODE GiveFeedback(DROPEFFECT dropEffect);
virtual BOOL OnBeginDrag(CWnd* pWnd);
// Implementation
public:
#ifdef _DEBUG
virtual void Dump(CDumpContext& dc) const;
#endif
public:
BEGIN_INTERFACE_PART(DropSource, IDropSource)
INIT_INTERFACE_PART(COleDropSource, DropSource)
STDMETHOD(QueryContinueDrag)(BOOL, DWORD);
STDMETHOD(GiveFeedback)(DWORD);
END_INTERFACE_PART(DropSource)
DECLARE_INTERFACE_MAP()
CRect m_rectStartDrag; // when mouse leaves this rect, drag drop starts
BOOL m_bDragStarted; // has drag really started yet?
DWORD m_dwButtonCancel; // which button will cancel (going down)
DWORD m_dwButtonDrop; // which button will confirm (going up)
// metrics for drag start determination
static AFX_DATA UINT nDragMinDist; // min. amount mouse must move for drag
static AFX_DATA UINT nDragDelay; // delay before drag starts
friend class COleDataSource;
};
/////////////////////////////////////////////////////////////////////////////
// COleDropTarget (advanced drop target support)
class COleDropTarget : public CCmdTarget
{
// Constructors
public:
COleDropTarget();
// Operations
BOOL Register(CWnd* pWnd);
virtual void Revoke(); // virtual for implementation
// Overridables
virtual DROPEFFECT OnDragEnter(CWnd* pWnd, COleDataObject* pDataObject,
DWORD dwKeyState, CPoint point);
virtual DROPEFFECT OnDragOver(CWnd* pWnd, COleDataObject* pDataObject,
DWORD dwKeyState, CPoint point);
virtual BOOL OnDrop(CWnd* pWnd, COleDataObject* pDataObject,
DROPEFFECT dropEffect, CPoint point);
virtual DROPEFFECT OnDropEx(CWnd* pWnd, COleDataObject* pDataObject,
DROPEFFECT dropDefault, DROPEFFECT dropList, CPoint point);
virtual void OnDragLeave(CWnd* pWnd);
virtual DROPEFFECT OnDragScroll(CWnd* pWnd, DWORD dwKeyState,
CPoint point);
// Implementation
public:
virtual ~COleDropTarget();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
HWND m_hWnd; // HWND this IDropTarget is attached to
LPDATAOBJECT m_lpDataObject; // != NULL between OnDragEnter, OnDragLeave
UINT m_nTimerID; // != MAKEWORD(-1, -1) when in scroll area
DWORD m_dwLastTick; // only valid when m_nTimerID valid
UINT m_nScrollDelay; // time to next scroll
// metrics for drag-scrolling
static AFX_DATA int nScrollInset;
static AFX_DATA UINT nScrollDelay;
static AFX_DATA UINT nScrollInterval;
// implementation helpers
void SetupTimer(CView* pView, UINT nTimerID);
void CancelTimer(CWnd* pWnd);
// Interface Maps
public:
BEGIN_INTERFACE_PART(DropTarget, IDropTarget)
INIT_INTERFACE_PART(COleDropTarget, DropTarget)
STDMETHOD(DragEnter)(LPDATAOBJECT, DWORD, POINTL, LPDWORD);
STDMETHOD(DragOver)(DWORD, POINTL, LPDWORD);
STDMETHOD(DragLeave)();
STDMETHOD(Drop)(LPDATAOBJECT, DWORD, POINTL pt, LPDWORD);
END_INTERFACE_PART(DropTarget)
DECLARE_INTERFACE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
// COleMessageFilter (implements IMessageFilter)
class COleMessageFilter : public CCmdTarget
{
// Constructors
public:
COleMessageFilter();
// Operations
BOOL Register();
void Revoke();
// for controlling the busy state of the server application (called app)
virtual void BeginBusyState();
virtual void EndBusyState();
void SetBusyReply(SERVERCALL nBusyReply);
// for controlling actions taken against rejected/retried calls
void SetRetryReply(DWORD nRetryReply = 0);
// only used when the "not responding" dialog is disabled
void SetMessagePendingDelay(DWORD nTimeout = 5000);
// used to determine amount of time before significant message
void EnableBusyDialog(BOOL bEnableBusy = TRUE);
void EnableNotRespondingDialog(BOOL bEnableNotResponding = TRUE);
// used to enable/disable the two types of busy dialogs
// Overridables
virtual BOOL OnMessagePending(const MSG* pMsg);
// return TRUE to eat the message (usually only if processed)
// Implementation
public:
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
virtual ~COleMessageFilter();
virtual BOOL IsSig
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -