You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1564 lines
54 KiB
1564 lines
54 KiB
// Microsoft Foundation Classes C++ library.
|
|
// Copyright (C) 1993 Microsoft Corporation,
|
|
// All rights reserved.
|
|
|
|
// This source code is only intended as a supplement to the
|
|
// Microsoft Foundation Classes Reference and Microsoft
|
|
// QuickHelp and/or WinHelp documentation provided with the library.
|
|
// See these sources for detailed information regarding the
|
|
// Microsoft Foundation Classes product.
|
|
|
|
|
|
#ifndef __AFXOLE_H__
|
|
#define __AFXOLE_H__
|
|
|
|
#ifndef __AFXEXT_H__
|
|
#include <afxext.h>
|
|
#endif
|
|
|
|
#ifndef __AFXDISP_H__
|
|
#include <afxdisp.h>
|
|
#endif
|
|
|
|
// include OLE 2.0 Compound Document interfaces
|
|
#define FARSTRUCT
|
|
#include <ole2.h>
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// AFXOLE.H - MFC OLE support
|
|
|
|
// Classes declared in this file
|
|
|
|
//CDocument
|
|
class COleDocument; // OLE container document
|
|
class COleLinkingDoc; // supports links to embeddings
|
|
class COleServerDoc; // OLE server document
|
|
|
|
//CCmdTarget
|
|
class CDocItem; // part of a document
|
|
class COleClientItem; // embedded ole object from outside
|
|
class COleServerItem; // ole object to export
|
|
class COleDataSource; // clipboard data source mechanism
|
|
class COleDropSource; // drag/drop source
|
|
class COleDropTarget; // drag/drop target
|
|
class COleMessageFilter; // concurrency management
|
|
|
|
//CFrameWnd
|
|
class COleIPFrameWnd; // frame window for in-place servers
|
|
|
|
//CControlBar
|
|
class COleResizeBar; // implements in-place resizing
|
|
|
|
//CFile
|
|
class COleStreamFile; // CFile wrapper for IStream interface
|
|
|
|
class COleDataObject; // wrapper for IDataObject interface
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// AFXDLL support
|
|
#undef AFXAPP_DATA
|
|
#define AFXAPP_DATA AFXAPIEX_DATA
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// backward compatibility
|
|
|
|
// COleClientDoc is now obsolete -- use COleDocument instead
|
|
#define COleClientDoc COleDocument
|
|
|
|
// COleServer has been replaced by the more general COleObjectFactory
|
|
#define COleServer COleObjectFactory
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// Useful OLE specific types (some from OLE 1.0 headers)
|
|
|
|
// Codes for CallBack events
|
|
enum OLE_NOTIFICATION
|
|
{
|
|
OLE_CHANGED, // representation of a draw aspect has changed
|
|
OLE_SAVED, // the item has committed its storage
|
|
OLE_CLOSED, // the item has closed
|
|
OLE_RENAMED, // the item has changed its moniker
|
|
OLE_CHANGED_STATE, // the item state (open, active, etc.) has changed
|
|
OLE_CHANGED_ASPECT, // the item draw aspect has changed
|
|
};
|
|
|
|
// Object types
|
|
enum OLE_OBJTYPE
|
|
{
|
|
OT_UNKNOWN = 0,
|
|
|
|
// These are OLE 1.0 types and OLE 2.0 types as returned from GetType().
|
|
OT_LINK = 1,
|
|
OT_EMBEDDED = 2,
|
|
OT_STATIC = 3,
|
|
|
|
// All OLE2 objects are written with this tag when serialized. This
|
|
// differentiates them from OLE 1.0 objects written with MFC 2.0.
|
|
// This value will never be returned from GetType().
|
|
OT_OLE2 = 256,
|
|
};
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// COleDataObject -- simple wrapper for IDataObject
|
|
|
|
class COleDataObject
|
|
{
|
|
// Constructors
|
|
public:
|
|
COleDataObject();
|
|
|
|
// Operations
|
|
void Attach(LPDATAOBJECT lpDataObject, BOOL bAutoRelease = TRUE);
|
|
LPDATAOBJECT Detach(); // detach and get ownership of m_lpDataObject
|
|
void Release(); // detach and Release ownership of m_lpDataObject
|
|
BOOL AttachClipboard(); // attach to current clipboard object
|
|
|
|
// Attributes
|
|
void BeginEnumFormats();
|
|
BOOL GetNextFormat(LPFORMATETC lpFormatEtc);
|
|
CFile* GetFileData(CLIPFORMAT cfFormat, LPFORMATETC lpFormatEtc = NULL);
|
|
HGLOBAL GetGlobalData(CLIPFORMAT cfFormat, LPFORMATETC lpFormatEtc = NULL);
|
|
BOOL GetData(CLIPFORMAT cfFormat, LPSTGMEDIUM lpStgMedium,
|
|
LPFORMATETC lpFormatEtc = NULL);
|
|
BOOL IsDataAvailable(CLIPFORMAT cfFormat, LPFORMATETC lpFormatEtc = NULL);
|
|
|
|
// Implementation
|
|
public:
|
|
LPDATAOBJECT m_lpDataObject;
|
|
LPENUMFORMATETC m_lpEnumerator;
|
|
~COleDataObject();
|
|
|
|
protected:
|
|
BOOL m_bAutoRelease; // TRUE if destructor should call Release
|
|
|
|
private:
|
|
// Disable the copy constructor and assignment by default so you will get
|
|
// compiler errors instead of unexpected behaviour if you pass objects
|
|
// by value or assign objects.
|
|
COleDataObject(const COleDataObject&); // no implementation
|
|
void operator=(const COleDataObject&); // no implementation
|
|
};
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// COleDataSource -- wrapper for implementing IDataObject
|
|
// (works similar to how data is provided on the clipboard)
|
|
|
|
struct AFX_DATACACHE_ENTRY;
|
|
class COleDropSource;
|
|
|
|
class COleDataSource : public CCmdTarget
|
|
{
|
|
// Constructors
|
|
public:
|
|
COleDataSource();
|
|
|
|
// Operations
|
|
void Empty(); // empty cache (similar to ::EmptyClipboard)
|
|
|
|
// CacheData & DelayRenderData operations similar to ::SetClipboardData
|
|
void CacheGlobalData(CLIPFORMAT cfFormat, HGLOBAL hGlobal,
|
|
LPFORMATETC lpFormatEtc = NULL); // for HGLOBAL based data
|
|
void DelayRenderFileData(CLIPFORMAT cfFormat,
|
|
LPFORMATETC lpFormatEtc = NULL); // for CFile* based delayed render
|
|
|
|
// Clipboard and Drag/Drop access
|
|
DROPEFFECT DoDragDrop(
|
|
DWORD dwEffects = DROPEFFECT_COPY|DROPEFFECT_MOVE|DROPEFFECT_LINK,
|
|
LPCRECT lpRectStartDrag = NULL,
|
|
COleDropSource* pDropSource = NULL);
|
|
void SetClipboard();
|
|
static void PASCAL FlushClipboard();
|
|
static COleDataSource* PASCAL GetClipboardOwner();
|
|
|
|
// Advanced: STGMEDIUM based cached data
|
|
void CacheData(CLIPFORMAT cfFormat, LPSTGMEDIUM lpStgMedium,
|
|
LPFORMATETC lpFormatEtc = NULL); // for LPSTGMEDIUM based data
|
|
// Advanced: STGMEDIUM or HGLOBAL based delayed render
|
|
void DelayRenderData(CLIPFORMAT cfFormat, LPFORMATETC lpFormatEtc = NULL);
|
|
|
|
// Advanced: support for SetData in COleServerItem
|
|
// (not generally useful for clipboard or drag/drop operations)
|
|
void DelaySetData(CLIPFORMAT cfFormat, LPFORMATETC lpFormatEtc = NULL);
|
|
|
|
// Overidables
|
|
virtual BOOL OnRenderGlobalData(LPFORMATETC lpFormatEtc, HGLOBAL* phGlobal);
|
|
virtual BOOL OnRenderFileData(LPFORMATETC lpFormatEtc, CFile* pFile);
|
|
virtual BOOL OnRenderData(LPFORMATETC lpFormatEtc, LPSTGMEDIUM lpStgMedium);
|
|
// OnRenderFileData and OnRenderGlobalData are called by
|
|
// the default implementation of OnRenderData.
|
|
|
|
#ifdef _AFXCTL
|
|
virtual BOOL OnSetData(LPFORMATETC lpFormatEtc, LPSTGMEDIUM lpStgMedium,
|
|
BOOL fRelease);
|
|
#else
|
|
virtual BOOL OnSetData(LPFORMATETC lpFormatEtc, LPSTGMEDIUM lpStgMedium);
|
|
// used only in COleServerItem implementation
|
|
#endif
|
|
|
|
// Implementation
|
|
public:
|
|
virtual ~COleDataSource();
|
|
#ifdef _DEBUG
|
|
virtual void AssertValid() const;
|
|
virtual void Dump(CDumpContext& dc) const;
|
|
#endif
|
|
|
|
protected:
|
|
AFX_DATACACHE_ENTRY* m_pDataCache; // data cache itself
|
|
UINT m_nMaxSize; // current allocated size
|
|
UINT m_nSize; // current size of the cache
|
|
UINT m_nGrowBy; // number of cache elements to grow by for new allocs
|
|
|
|
AFX_DATACACHE_ENTRY* Lookup(LPFORMATETC lpFormatEtc,
|
|
DATADIR dataDir) const;
|
|
AFX_DATACACHE_ENTRY* AllocSpace();
|
|
|
|
// Interface Maps
|
|
public:
|
|
BEGIN_INTERFACE_PART(DataObject, IDataObject)
|
|
STDMETHOD(GetData)(LPFORMATETC, LPSTGMEDIUM);
|
|
STDMETHOD(GetDataHere)(LPFORMATETC, LPSTGMEDIUM);
|
|
STDMETHOD(QueryGetData)(LPFORMATETC);
|
|
STDMETHOD(GetCanonicalFormatEtc)(LPFORMATETC, LPFORMATETC);
|
|
STDMETHOD(SetData)(LPFORMATETC, LPSTGMEDIUM, BOOL);
|
|
STDMETHOD(EnumFormatEtc)(DWORD, LPENUMFORMATETC FAR*);
|
|
STDMETHOD(DAdvise)(LPFORMATETC, DWORD, LPADVISESINK, LPDWORD);
|
|
STDMETHOD(DUnadvise)(DWORD);
|
|
STDMETHOD(EnumDAdvise)(LPENUMSTATDATA FAR*);
|
|
END_INTERFACE_PART(DataObject)
|
|
|
|
DECLARE_INTERFACE_MAP()
|
|
|
|
friend class COleServerItem;
|
|
};
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
// DocItem support
|
|
|
|
class CDocItem : public CCmdTarget
|
|
{
|
|
DECLARE_SERIAL(CDocItem)
|
|
|
|
// Constructors
|
|
protected: // abstract class
|
|
CDocItem();
|
|
|
|
// Attributes
|
|
public:
|
|
CDocument* GetDocument() const; // return container document
|
|
|
|
// Overridables
|
|
public:
|
|
// Raw data access (native format)
|
|
virtual BOOL IsBlank() const;
|
|
|
|
// Implementation
|
|
protected:
|
|
COleDocument* m_pDocument;
|
|
|
|
public:
|
|
virtual void Serialize(CArchive& ar); // for Native data
|
|
virtual ~CDocItem();
|
|
#ifdef _DEBUG
|
|
virtual void AssertValid() const;
|
|
virtual void Dump(CDumpContext& dc) const;
|
|
#endif
|
|
|
|
friend class COleDocument; // for access to back pointer
|
|
};
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
// COleDocument - common OLE container behavior (enables server functionality)
|
|
|
|
class COleDocument : public CDocument
|
|
{
|
|
DECLARE_DYNAMIC(COleDocument)
|
|
|
|
// Constructors
|
|
public:
|
|
COleDocument();
|
|
|
|
// Attributes
|
|
BOOL HasBlankItems() const; // check for BLANK items
|
|
COleClientItem* GetInPlaceActiveItem(CWnd* pWnd);
|
|
// return in-place active item for this view or NULL if none
|
|
|
|
// Operations
|
|
// iterating over existing items
|
|
virtual POSITION GetStartPosition() const;
|
|
virtual CDocItem* GetNextItem(POSITION& pos) const;
|
|
|
|
// iterator helpers (helpers use virtual GetNextItem above)
|
|
COleClientItem* GetNextClientItem(POSITION& pos) const;
|
|
COleServerItem* GetNextServerItem(POSITION& pos) const;
|
|
|
|
// adding new items - called from item constructors
|
|
virtual void AddItem(CDocItem* pItem);
|
|
virtual void RemoveItem(CDocItem* pItem);
|
|
|
|
void EnableCompoundFile(BOOL bEnable = TRUE);
|
|
// enable compound file support (only call during constructor)
|
|
void UpdateModifiedFlag();
|
|
// scan for modified items -- mark document modified
|
|
|
|
// printer-device caching/control
|
|
BOOL ApplyPrintDevice(const DVTARGETDEVICE FAR* ptd);
|
|
BOOL ApplyPrintDevice(const PRINTDLG* ppd);
|
|
// these apply the target device to all COleClientItem objects
|
|
|
|
// Overridables
|
|
virtual COleClientItem* GetPrimarySelectedItem(CView* pView);
|
|
// return primary selected item or NULL if none
|
|
virtual void OnShowViews(BOOL bVisible);
|
|
// called during app-idle when visibility of a document has changed
|
|
|
|
// Implementation
|
|
public:
|
|
CObList m_docItemList; // not owned items
|
|
|
|
#ifdef _DEBUG
|
|
virtual void AssertValid() const;
|
|
virtual void Dump(CDumpContext& dc) const;
|
|
#endif
|
|
CFrameWnd* GetFirstFrame();
|
|
|
|
// document handling overrides
|
|
virtual void SetPathName(const char* pszPathName, BOOL bAddToMRU = TRUE);
|
|
virtual ~COleDocument();
|
|
virtual void DeleteContents(); // delete client items in list
|
|
virtual void Serialize(CArchive& ar); // serialize items to file
|
|
virtual void PreCloseFrame(CFrameWnd* pFrame);
|
|
virtual BOOL SaveModified();
|
|
virtual void OnIdle();
|
|
|
|
// compound file implementation
|
|
virtual BOOL OnNewDocument();
|
|
virtual BOOL OnOpenDocument(const char* pszPathName);
|
|
virtual BOOL OnSaveDocument(const char* pszPathName);
|
|
virtual void OnCloseDocument();
|
|
void CommitItems(BOOL bSuccess); // called during File.Save & File.Save As
|
|
|
|
// minimal linking protocol
|
|
virtual LPMONIKER GetMoniker(OLEGETMONIKER nAssign);
|
|
virtual LPOLEITEMCONTAINER GetContainer();
|
|
|
|
protected:
|
|
DWORD m_dwNextItemNumber; // serial number for next item in this document
|
|
BOOL m_bLastVisible; // TRUE if one or more views was last visible
|
|
|
|
// 'docfile' support
|
|
BOOL m_bCompoundFile; // TRUE if use compound files
|
|
LPSTORAGE m_lpRootStg; // root storage for the document
|
|
BOOL m_bSameAsLoad; // TRUE = file-save, FALSE = Save [Copy] As
|
|
BOOL m_bRemember; // if FALSE, indicates Save Copy As
|
|
|
|
DVTARGETDEVICE FAR* m_ptd; // current document target device
|
|
|
|
// implementation helpers
|
|
virtual void LoadFromStorage();
|
|
virtual void SaveToStorage(CObject* pObject = NULL);
|
|
CDocItem* GetNextItemOfKind(POSITION& pos, CRuntimeClass* pClass) const;
|
|
|
|
// command handling
|
|
virtual BOOL OnCmdMsg(UINT nID, int nCode, void* pExtra,
|
|
AFX_CMDHANDLERINFO* pHandlerInfo);
|
|
|
|
afx_msg void OnUpdatePasteMenu(CCmdUI* pCmdUI);
|
|
afx_msg void OnUpdatePasteLinkMenu(CCmdUI* pCmdUI);
|
|
afx_msg void OnUpdateEditLinksMenu(CCmdUI* pCmdUI);
|
|
afx_msg void OnEditLinks();
|
|
afx_msg void OnEditConvert();
|
|
afx_msg void OnUpdateEditChangeIcon(CCmdUI* pCmdUI);
|
|
afx_msg void OnEditChangeIcon();
|
|
afx_msg void OnUpdateObjectVerbMenu(CCmdUI* pCmdUI);
|
|
afx_msg void OnFileSendMail();
|
|
|
|
friend class COleClientItem;
|
|
friend class COleServerItem;
|
|
};
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// COleClientItem - Supports OLE2 non-inplace editing.
|
|
// implements IOleClientSite, IAdviseSink, and IOleInPlaceSite
|
|
|
|
class COleFrameHook; // special implementation class
|
|
|
|
class COleClientItem : public CDocItem
|
|
{
|
|
DECLARE_DYNAMIC(COleClientItem)
|
|
|
|
// Constructors
|
|
public:
|
|
COleClientItem(COleDocument* pContainerDoc = NULL);
|
|
|
|
// create from the clipboard
|
|
BOOL CreateFromClipboard(OLERENDER render = OLERENDER_DRAW,
|
|
CLIPFORMAT cfFormat = 0, LPFORMATETC lpFormatEtc = NULL);
|
|
BOOL CreateLinkFromClipboard(OLERENDER render = OLERENDER_DRAW,
|
|
CLIPFORMAT cfFormat = 0, LPFORMATETC lpFormatEtc = NULL);
|
|
BOOL CreateStaticFromClipboard(OLERENDER render = OLERENDER_DRAW,
|
|
CLIPFORMAT cfFormat = 0, LPFORMATETC lpFormatEtc = NULL);
|
|
|
|
// create from a class ID (Insert New Object dialog)
|
|
BOOL CreateNewItem(REFCLSID clsid, OLERENDER render = OLERENDER_DRAW,
|
|
CLIPFORMAT cfFormat = 0, LPFORMATETC lpFormatEtc = NULL);
|
|
|
|
// create from COleDataObject
|
|
BOOL CreateFromData(COleDataObject* pDataObject,
|
|
OLERENDER render = OLERENDER_DRAW,
|
|
CLIPFORMAT cfFormat = 0, LPFORMATETC lpFormatEtc = NULL);
|
|
BOOL CreateLinkFromData(COleDataObject* pDataObject,
|
|
OLERENDER render = OLERENDER_DRAW,
|
|
CLIPFORMAT cfFormat = 0, LPFORMATETC lpFormatEtc = NULL);
|
|
BOOL CreateStaticFromData(COleDataObject* pDataObject,
|
|
OLERENDER render = OLERENDER_DRAW,
|
|
CLIPFORMAT cfFormat = 0, LPFORMATETC lpFormatEtc = NULL);
|
|
|
|
// create from file (package support)
|
|
BOOL CreateFromFile(LPCSTR lpszFileName, REFCLSID clsid = CLSID_NULL,
|
|
OLERENDER render = OLERENDER_DRAW,
|
|
CLIPFORMAT cfFormat = 0, LPFORMATETC lpFormatEtc = NULL);
|
|
BOOL CreateLinkFromFile(LPCSTR lpszFileName,
|
|
OLERENDER render = OLERENDER_DRAW,
|
|
CLIPFORMAT cfFormat = 0, LPFORMATETC lpFormatEtc = NULL);
|
|
|
|
// create a copy
|
|
BOOL CreateCloneFrom(COleClientItem* pSrcItem);
|
|
|
|
// General Attributes
|
|
public:
|
|
SCODE GetLastStatus() const;
|
|
OLE_OBJTYPE GetType() const; // OT_LINK, OT_EMBEDDED, OT_STATIC
|
|
void GetClassID(CLSID FAR* pClassID) const;
|
|
void GetUserType(USERCLASSTYPE nUserClassType, CString& rString);
|
|
BOOL GetExtent(LPSIZE lpSize, DVASPECT nDrawAspect = (DVASPECT)-1);
|
|
// will return FALSE if item is BLANK
|
|
|
|
HGLOBAL GetIconicMetafile();
|
|
BOOL SetIconicMetafile(HGLOBAL hMetaPict);
|
|
// getting/setting iconic cache
|
|
|
|
DVASPECT GetDrawAspect() const;
|
|
void SetDrawAspect(DVASPECT nDrawAspect);
|
|
// setting/getting default display aspect
|
|
|
|
// for printer presentation cache
|
|
BOOL SetPrintDevice(const DVTARGETDEVICE FAR* ptd);
|
|
BOOL SetPrintDevice(const PRINTDLG* ppd);
|
|
|
|
// Item state
|
|
enum ItemState
|
|
{ emptyState, loadedState, openState, activeState, activeUIState };
|
|
UINT GetItemState() const;
|
|
|
|
BOOL IsModified() const;
|
|
BOOL IsRunning() const;
|
|
BOOL IsInPlaceActive() const;
|
|
BOOL IsOpen() const;
|
|
CView* GetActiveView() const;
|
|
|
|
// Data access
|
|
void AttachDataObject(COleDataObject& rDataObject) const;
|
|
|
|
// other rare access information
|
|
COleDocument* GetDocument() const; // return container
|
|
|
|
// helpers for checking clipboard data availability
|
|
static BOOL PASCAL CanPaste();
|
|
static BOOL PASCAL CanPasteLink();
|
|
|
|
// helpers for checking COleDataObject, useful in drag drop
|
|
static BOOL PASCAL CanCreateFromData(const COleDataObject* pDataObject);
|
|
static BOOL PASCAL CanCreateLinkFromData(const COleDataObject* pDataObject);
|
|
|
|
// General Operations
|
|
virtual void Release(OLECLOSE dwCloseOption = OLECLOSE_NOSAVE);
|
|
// cleanup, detach (close if needed)
|
|
void Close(OLECLOSE dwCloseOption = OLECLOSE_SAVEIFDIRTY);
|
|
// close without releasing the item
|
|
void Delete(BOOL bAutoDelete = TRUE);
|
|
// logically delete from file -- not part of the document anymore
|
|
void Run(); // insure item is in running state
|
|
|
|
// Drawing
|
|
BOOL Draw(CDC* pDC, LPCRECT lpBounds,
|
|
DVASPECT nDrawAspect = (DVASPECT)-1); // defaults to m_nDrawAspect
|
|
|
|
// Activation
|
|
virtual BOOL DoVerb(LONG nVerb, CView* pView, LPMSG lpMsg = NULL);
|
|
void Activate(LONG nVerb, CView* pView, LPMSG lpMsg = NULL);
|
|
|
|
// In-place Activation
|
|
void Deactivate(); // completely deactivate
|
|
void DeactivateUI(); // deactivate the user interface
|
|
BOOL ReactivateAndUndo(); // reactivate then perform undo command
|
|
BOOL SetItemRects(LPCRECT lpPosRect = NULL, LPCRECT lpClipRect = NULL);
|
|
CWnd* GetInPlaceWindow();
|
|
|
|
// Clipboard operations
|
|
void CopyToClipboard(BOOL bIncludeLink = FALSE);
|
|
DROPEFFECT DoDragDrop(LPCRECT lpItemRect, CPoint ptOffset,
|
|
BOOL bIncludeLink = FALSE,
|
|
DWORD dwEffects = DROPEFFECT_COPY|DROPEFFECT_MOVE,
|
|
LPCRECT lpRectStartDrag = NULL);
|
|
void GetClipboardData(COleDataSource* pDataSource,
|
|
BOOL bIncludeLink = FALSE, LPPOINT lpOffset = NULL,
|
|
LPSIZE lpSize = NULL);
|
|
|
|
// called for creating a COleDataSource by CopyToClipboard and DoDragDrop
|
|
virtual COleDataSource* OnGetClipboardData(BOOL bIncludeLink,
|
|
LPPOINT lpOffset, LPSIZE lpSize);
|
|
|
|
// Operations that apply to embedded items only
|
|
void SetHostNames(LPCSTR lpszHost, LPCSTR lpszHostObj);
|
|
void SetExtent(const CSize& size, DVASPECT nDrawAspect = DVASPECT_CONTENT);
|
|
|
|
// Operations that apply to linked items only
|
|
// (link options are rarely changed, except through Links dialog)
|
|
OLEUPDATE GetLinkUpdateOptions();
|
|
void SetLinkUpdateOptions(OLEUPDATE dwUpdateOpt);
|
|
|
|
// Link-source update status (also useful for embeddings that contain links)
|
|
BOOL UpdateLink(); // make up-to-date
|
|
BOOL IsLinkUpToDate() const; // is link up-to-date
|
|
|
|
// object conversion
|
|
BOOL ConvertTo(REFCLSID clsidNew);
|
|
BOOL ActivateAs(LPCSTR lpszUserType, REFCLSID clsidOld, REFCLSID clsidNew);
|
|
BOOL Reload(); // for lazy reload after ActivateAs
|
|
|
|
// Overridables (notifications of IAdviseSink, IOleClientSite and IOleInPlaceSite)
|
|
// Callbacks/notifications from the server you must/should implement
|
|
virtual void OnChange(OLE_NOTIFICATION nCode, DWORD dwParam);
|
|
// implement OnChange to invalidate when item changes
|
|
|
|
protected:
|
|
virtual void OnGetItemPosition(CRect& rPosition);
|
|
// implement OnGetItemPosition if you support in-place activation
|
|
|
|
// Common overrides for in-place activation
|
|
virtual BOOL OnScrollBy(CSize sizeExtent);
|
|
|
|
protected:
|
|
// Common overrides for applications supporting undo
|
|
virtual void OnDeactivateUI(BOOL bUndoable);
|
|
virtual void OnDiscardUndoState();
|
|
virtual void OnDeactivateAndUndo();
|
|
|
|
// Common overrides for applications supporting links to embeddings
|
|
virtual void OnShowItem();
|
|
|
|
// Advanced overrides for in-place activation
|
|
virtual void OnGetClipRect(CRect& rClipRect);
|
|
virtual BOOL CanActivate();
|
|
virtual void OnActivate();
|
|
virtual void OnActivateUI();
|
|
virtual BOOL OnGetWindowContext(CFrameWnd** ppMainFrame,
|
|
CFrameWnd** ppDocFrame, LPOLEINPLACEFRAMEINFO lpFrameInfo);
|
|
virtual void OnDeactivate();
|
|
virtual BOOL OnChangeItemPosition(const CRect& rectPos);
|
|
// default calls SetItemRects and caches the pos rect
|
|
|
|
public:
|
|
// Advanced overrides for menu/title handling (rarely overridden)
|
|
virtual void OnInsertMenus(CMenu* pMenuShared,
|
|
LPOLEMENUGROUPWIDTHS lpMenuWidths);
|
|
virtual void OnSetMenu(CMenu* pMenuShared, HOLEMENU holemenu,
|
|
HWND hwndActiveObject);
|
|
virtual void OnRemoveMenus(CMenu* pMenuShared);
|
|
virtual void OnUpdateFrameTitle();
|
|
|
|
// Advanced override for control bar handling
|
|
virtual BOOL OnShowControlBars(CFrameWnd* pFrameWnd, BOOL bShow);
|
|
|
|
// Implementation
|
|
public:
|
|
// data to support non-inplace activated items
|
|
LPOLEOBJECT m_lpObject; // in case you want direct access to the OLE object
|
|
DWORD m_dwItemNumber; // serial number for this item in this document
|
|
DVASPECT m_nDrawAspect; // current default display aspect
|
|
SCODE m_scLast; // last error code encountered
|
|
LPSTORAGE m_lpStorage; // provides storage for m_lpObject
|
|
LPLOCKBYTES m_lpLockBytes; // part of implementation of m_lpStorage
|
|
DWORD m_dwConnection; // advise connection to the m_lpObject
|
|
BYTE m_bLinkUnavail; // TRUE if link is currently unavailable
|
|
BYTE m_bMoniker; // TRUE if moniker is assigned
|
|
BYTE m_bLocked; // TRUE if object has external lock
|
|
BYTE m_bNeedCommit; // TRUE if need CommitItem
|
|
BYTE m_bClosing; // TRUE if currently doing COleClientItem::Close
|
|
BYTE m_bReserved; // (reserved for future use)
|
|
|
|
// for compound file support
|
|
LPSTORAGE m_lpNewStorage; // used during Save As situations
|
|
|
|
// item state & item type
|
|
ItemState m_nItemState; // item state (see ItemState enumeration)
|
|
OLE_OBJTYPE m_nItemType; // item type (depends on how created)
|
|
|
|
// data valid when in-place activated
|
|
CView* m_pView; // view when object is in-place activated
|
|
DWORD m_dwContainerStyle; // style of the container wnd before activation
|
|
COleFrameHook* m_pInPlaceFrame;// frame window when in-place active
|
|
COleFrameHook* m_pInPlaceDoc; // doc window when in-place (may be NULL)
|
|
HWND m_hWndServer; // HWND of in-place server window
|
|
|
|
public:
|
|
virtual ~COleClientItem();
|
|
virtual void Serialize(CArchive& ar);
|
|
#ifdef _DEBUG
|
|
virtual void AssertValid() const;
|
|
virtual void Dump(CDumpContext& dc) const;
|
|
#endif
|
|
|
|
// Implementation
|
|
public:
|
|
virtual BOOL ReportError(SCODE sc) const;
|
|
virtual BOOL FreezeLink(); // converts to static: for edit links dialog
|
|
|
|
DWORD GetNewItemNumber(); // generates new item number
|
|
void GetItemName(char* pszItemName) const; // gets readable item name
|
|
|
|
void UpdateItemType(); // update m_nItemType
|
|
|
|
protected:
|
|
// clipboard helpers
|
|
void GetEmbeddedItemData(LPSTGMEDIUM lpStgMedium);
|
|
void AddCachedData(COleDataSource* pDataSource);
|
|
BOOL GetLinkSourceData(LPSTGMEDIUM lpStgMedium);
|
|
void GetObjectDescriptorData(LPPOINT lpOffset, LPSIZE lpSize,
|
|
LPSTGMEDIUM lpStgMedium);
|
|
|
|
// interface helpers
|
|
LPOLECLIENTSITE GetClientSite();
|
|
|
|
// helpers for printer-cached representation
|
|
BOOL GetPrintDeviceInfo(LPOLECACHE* plpOleCache,
|
|
DVTARGETDEVICE FAR** pptd, DWORD* pdwConnection);
|
|
|
|
// Advanced Overridables for implementation
|
|
protected:
|
|
virtual BOOL FinishCreate(HRESULT hr);
|
|
virtual void CheckGeneral(HRESULT hr);
|
|
|
|
virtual void OnDataChange(LPFORMATETC lpFormatEtc,
|
|
LPSTGMEDIUM lpStgMedium);
|
|
|
|
public:
|
|
// for storage hookability (override to use 'docfiles')
|
|
virtual void GetItemStorage(); // allocate storage for new item
|
|
virtual void ReadItem(CArchive& ar); // read item from archive
|
|
virtual void WriteItem(CArchive& ar); // write item to archive
|
|
virtual void CommitItem(BOOL bSuccess); // commit item's storage
|
|
|
|
// compound & flat file implementations of above
|
|
void GetItemStorageFlat();
|
|
void ReadItemFlat(CArchive& ar);
|
|
void WriteItemFlat(CArchive& ar);
|
|
void GetItemStorageCompound();
|
|
void ReadItemCompound(CArchive& ar);
|
|
void WriteItemCompound(CArchive& ar);
|
|
|
|
private:
|
|
static CView* pActivateView; // activation view
|
|
|
|
// Interface Maps
|
|
protected:
|
|
BEGIN_INTERFACE_PART(OleClientSite, IOleClientSite)
|
|
STDMETHOD(SaveObject)();
|
|
STDMETHOD(GetMoniker)(DWORD, DWORD, LPMONIKER FAR*);
|
|
STDMETHOD(GetContainer)(LPOLECONTAINER FAR*);
|
|
STDMETHOD(ShowObject)();
|
|
STDMETHOD(OnShowWindow)(BOOL);
|
|
STDMETHOD(RequestNewObjectLayout)();
|
|
END_INTERFACE_PART(OleClientSite)
|
|
|
|
BEGIN_INTERFACE_PART(AdviseSink, IAdviseSink)
|
|
STDMETHOD_(void,OnDataChange)(LPFORMATETC, LPSTGMEDIUM);
|
|
STDMETHOD_(void,OnViewChange)(DWORD, LONG);
|
|
STDMETHOD_(void,OnRename)(LPMONIKER);
|
|
STDMETHOD_(void,OnSave)();
|
|
STDMETHOD_(void,OnClose)();
|
|
END_INTERFACE_PART(AdviseSink)
|
|
|
|
BEGIN_INTERFACE_PART(OleIPSite, IOleInPlaceSite)
|
|
STDMETHOD(GetWindow)(HWND FAR*);
|
|
STDMETHOD(ContextSensitiveHelp)(BOOL);
|
|
STDMETHOD(CanInPlaceActivate)();
|
|
STDMETHOD(OnInPlaceActivate)();
|
|
STDMETHOD(OnUIActivate)();
|
|
STDMETHOD(GetWindowContext)(LPOLEINPLACEFRAME FAR*,
|
|
LPOLEINPLACEUIWINDOW FAR*, LPRECT, LPRECT, LPOLEINPLACEFRAMEINFO);
|
|
STDMETHOD(Scroll)(SIZE);
|
|
STDMETHOD(OnUIDeactivate)(BOOL);
|
|
STDMETHOD(OnInPlaceDeactivate)();
|
|
STDMETHOD(DiscardUndoState)();
|
|
STDMETHOD(DeactivateAndUndo)();
|
|
STDMETHOD(OnPosRectChange)(LPCRECT);
|
|
END_INTERFACE_PART(OleIPSite)
|
|
|
|
DECLARE_INTERFACE_MAP()
|
|
|
|
// Friendship declarations (to avoid many public members)
|
|
friend class COleUIWindow;
|
|
friend class COleFrameWindow;
|
|
friend class COleLinkingDoc;
|
|
};
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// COleServerItem - IOleObject & IDataObject OLE component
|
|
|
|
class COleServerItem : public CDocItem
|
|
{
|
|
DECLARE_DYNAMIC(COleServerItem)
|
|
protected:
|
|
// NOTE: many members in this class are protected - since everything
|
|
// in this class is designed for implementing an OLE server.
|
|
// Requests will come from OLE containers through non-C++ mechanisms,
|
|
// which will result in virtual functions in this class being called.
|
|
|
|
// Constructors
|
|
COleServerItem(COleServerDoc* pServerDoc, BOOL bAutoDelete);
|
|
// If your COleServerItem is an integral part of your data,
|
|
// bAutoDelete should be FALSE. If your COleServerItem can be
|
|
// deleted when a link is released, it can be TRUE.
|
|
|
|
COleDataSource* GetDataSource();
|
|
// Use this data source to add conversion formats that your
|
|
// server should support. Usually such formats are
|
|
// added in the item's constructor.
|
|
|
|
// Public Attributes
|
|
public:
|
|
COleServerDoc* GetDocument() const; // return server document
|
|
|
|
// naming (for links only)
|
|
const CString& GetItemName() const; // get name of linked item
|
|
void SetItemName(const char* pszItemName); // set name of linked item
|
|
|
|
// link state
|
|
BOOL IsConnected() const; // returns TRUE if item has a client
|
|
BOOL IsLinkedItem() const; // returns TRUE if item is not embedded item
|
|
|
|
// extents
|
|
CSize m_sizeExtent;
|
|
// HIMETRIC size -- the default implementation of OnSetExtent
|
|
// updates this member variable. This member tells the server how
|
|
// much of the object is visible in the container document.
|
|
|
|
// Operations
|
|
public:
|
|
void NotifyChanged(DVASPECT nDrawAspect = DVASPECT_CONTENT);
|
|
// call this after you change item
|
|
void CopyToClipboard(BOOL bIncludeLink = FALSE);
|
|
// helper for implementing server 'copy to clipboard'
|
|
DROPEFFECT DoDragDrop(LPCRECT lpRectItem, CPoint ptOffset,
|
|
BOOL bIncludeLink = FALSE,
|
|
DWORD dwEffects = DROPEFFECT_COPY|DROPEFFECT_MOVE,
|
|
LPCRECT lpRectStartDrag = NULL);
|
|
void GetClipboardData(COleDataSource* pDataSource,
|
|
BOOL bIncludeLink = FALSE, LPPOINT lpOffset = NULL,
|
|
LPSIZE lpSize = NULL);
|
|
|
|
// Overridables
|
|
// overridables you must implement for yourself
|
|
virtual BOOL OnDraw(CDC* pDC, CSize& rSize) = 0;
|
|
// drawing for metafile format (return FALSE if not supported or error)
|
|
// (called for DVASPECT_CONTENT only)
|
|
|
|
// overridables you may want to implement yourself
|
|
virtual void OnUpdate(COleServerItem* pSender,
|
|
LPARAM lHint, CObject* pHint, DVASPECT nDrawAspect);
|
|
// the default implementation always calls NotifyChanged
|
|
|
|
virtual BOOL OnDrawEx(CDC* pDC, DVASPECT nDrawAspect, CSize& rSize);
|
|
// advanced drawing -- called for DVASPECT other than DVASPECT_CONTENT
|
|
virtual BOOL OnSetExtent(DVASPECT nDrawAspect, const CSize& size);
|
|
virtual BOOL OnGetExtent(DVASPECT nDrawAspect, CSize& rSize);
|
|
// default implementation uses m_sizeExtent
|
|
|
|
// overridables you do not have to implement
|
|
virtual void OnDoVerb(LONG iVerb);
|
|
// default routes to OnShow &/or OnOpen
|
|
virtual BOOL OnSetColorScheme(const LOGPALETTE FAR* lpLogPalette);
|
|
// default does nothing
|
|
virtual COleDataSource* OnGetClipboardData(BOOL bIncludeLink,
|
|
LPPOINT lpOffset, LPSIZE lpSize);
|
|
// called for access to clipboard data
|
|
virtual BOOL OnQueryUpdateItems();
|
|
// called to determine if there are any contained out-of-date links
|
|
virtual void OnUpdateItems();
|
|
// called to update any out-of-date links
|
|
|
|
protected:
|
|
virtual void OnShow();
|
|
// show item in the user interface (may edit in-place)
|
|
virtual void OnOpen();
|
|
// show item in the user interface (must open fully)
|
|
virtual void OnHide();
|
|
// hide document (and sometimes application)
|
|
|
|
// very advanced overridables
|
|
public:
|
|
virtual BOOL OnInitFromData(COleDataObject* pDataObject, BOOL bCreation);
|
|
// initialize object from IDataObject
|
|
|
|
// see COleDataSource for a description of these overridables
|
|
virtual BOOL OnRenderGlobalData(LPFORMATETC lpFormatEtc, HGLOBAL* phGlobal);
|
|
virtual BOOL OnRenderFileData(LPFORMATETC lpFormatEtc, CFile* pFile);
|
|
virtual BOOL OnRenderData(LPFORMATETC lpFormatEtc, LPSTGMEDIUM lpStgMedium);
|
|
// HGLOBAL version will be called first, then CFile* version
|
|
|
|
virtual BOOL OnSetData(LPFORMATETC lpFormatEtc, LPSTGMEDIUM lpStgMedium);
|
|
// Rare -- only if you support SetData (programmatic paste)
|
|
|
|
// advanced helpers for CopyToClipboard
|
|
void GetEmbedSourceData(LPSTGMEDIUM lpStgMedium);
|
|
void AddOtherClipboardData(COleDataSource* pDataSource);
|
|
BOOL GetLinkSourceData(LPSTGMEDIUM lpStgMedium);
|
|
void GetObjectDescriptorData(LPPOINT lpOffset, LPSIZE lpSize,
|
|
LPSTGMEDIUM lpStgMedium);
|
|
|
|
// Implementation
|
|
public:
|
|
BOOL m_bNeedUnlock; // if TRUE need to pDoc->LockExternal(FALSE)
|
|
BOOL m_bAutoDelete; // if TRUE will OnRelease will 'delete this'
|
|
|
|
// special version of OnFinalRelease to implement document locking
|
|
virtual void OnFinalRelease();
|
|
|
|
protected:
|
|
CString m_strItemName; // simple item name
|
|
|
|
public:
|
|
LPOLEADVISEHOLDER m_lpOleAdviseHolder; // may be NULL
|
|
LPDATAADVISEHOLDER m_lpDataAdviseHolder; // may be NULL
|
|
|
|
virtual ~COleServerItem();
|
|
#ifdef _DEBUG
|
|
virtual void AssertValid() const;
|
|
virtual void Dump(CDumpContext& dc) const;
|
|
#endif
|
|
|
|
// implementation helpers
|
|
void NotifyClient(OLE_NOTIFICATION wNotification, DWORD dwParam);
|
|
LPDATAOBJECT GetDataObject();
|
|
LPOLEOBJECT GetOleObject();
|
|
|
|
protected:
|
|
virtual BOOL GetMetafileData(LPFORMATETC lpFormatEtc, LPSTGMEDIUM pmedium);
|
|
// calls OnDraw or OnDrawEx
|
|
virtual void OnSaveEmbedding(LPSTORAGE lpStorage);
|
|
virtual BOOL IsBlank() const;
|
|
|
|
// CItemDataSource implements OnRender reflections to COleServerItem
|
|
class CItemDataSource : public COleDataSource
|
|
{
|
|
protected:
|
|
// the GetData and SetData interfaces forward to m_pItem
|
|
virtual BOOL OnRenderGlobalData(LPFORMATETC lpFormatEtc, HGLOBAL* phGlobal);
|
|
virtual BOOL OnRenderFileData(LPFORMATETC lpFormatEtc, CFile* pFile);
|
|
virtual BOOL OnRenderData(LPFORMATETC lpFormatEtc, LPSTGMEDIUM lpStgMedium);
|
|
// HGLOBAL version will be called first, then CFile* version
|
|
|
|
virtual BOOL OnSetData(LPFORMATETC lpFormatEtc, LPSTGMEDIUM lpStgMedium);
|
|
// HGLOBAL version will be called first, then CFile* version
|
|
};
|
|
CItemDataSource m_dataSource;
|
|
// data source used to implement IDataObject
|
|
|
|
// Interface Maps
|
|
// (Note: these interface maps are used just for link implementation)
|
|
public:
|
|
BEGIN_INTERFACE_PART(OleObject, IOleObject)
|
|
STDMETHOD(SetClientSite)(LPOLECLIENTSITE);
|
|
STDMETHOD(GetClientSite)(LPOLECLIENTSITE FAR*);
|
|
STDMETHOD(SetHostNames)(LPCSTR, LPCSTR);
|
|
STDMETHOD(Close)(DWORD);
|
|
STDMETHOD(SetMoniker)(DWORD, LPMONIKER);
|
|
STDMETHOD(GetMoniker)(DWORD, DWORD, LPMONIKER FAR*);
|
|
STDMETHOD(InitFromData)(LPDATAOBJECT, BOOL, DWORD);
|
|
STDMETHOD(GetClipboardData)(DWORD, LPDATAOBJECT FAR*);
|
|
STDMETHOD(DoVerb)(LONG, LPMSG, LPOLECLIENTSITE, LONG, HWND, LPCRECT);
|
|
STDMETHOD(EnumVerbs)(IEnumOLEVERB FAR* FAR*);
|
|
STDMETHOD(Update)();
|
|
STDMETHOD(IsUpToDate)();
|
|
STDMETHOD(GetUserClassID)(CLSID FAR*);
|
|
STDMETHOD(GetUserType)(DWORD, LPSTR FAR*);
|
|
STDMETHOD(SetExtent)(DWORD, LPSIZEL);
|
|
STDMETHOD(GetExtent)(DWORD, LPSIZEL);
|
|
STDMETHOD(Advise)(LPADVISESINK, LPDWORD);
|
|
STDMETHOD(Unadvise)(DWORD);
|
|
STDMETHOD(EnumAdvise)(LPENUMSTATDATA FAR*);
|
|
STDMETHOD(GetMiscStatus)(DWORD, LPDWORD);
|
|
STDMETHOD(SetColorScheme)(LPLOGPALETTE);
|
|
END_INTERFACE_PART(OleObject)
|
|
|
|
BEGIN_INTERFACE_PART(DataObject, IDataObject)
|
|
STDMETHOD(GetData)(LPFORMATETC, LPSTGMEDIUM);
|
|
STDMETHOD(GetDataHere)(LPFORMATETC, LPSTGMEDIUM);
|
|
STDMETHOD(QueryGetData)(LPFORMATETC);
|
|
STDMETHOD(GetCanonicalFormatEtc)(LPFORMATETC, LPFORMATETC);
|
|
STDMETHOD(SetData)(LPFORMATETC, LPSTGMEDIUM, BOOL);
|
|
STDMETHOD(EnumFormatEtc)(DWORD, LPENUMFORMATETC FAR*);
|
|
STDMETHOD(DAdvise)(LPFORMATETC, DWORD, LPADVISESINK, LPDWORD);
|
|
STDMETHOD(DUnadvise)(DWORD);
|
|
STDMETHOD(EnumDAdvise)(LPENUMSTATDATA FAR*);
|
|
END_INTERFACE_PART(DataObject)
|
|
|
|
DECLARE_INTERFACE_MAP()
|
|
|
|
friend class CItemDataSource;
|
|
friend class COleServerDoc;
|
|
friend class COleLinkingDoc;
|
|
};
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// COleLinkingDoc -
|
|
// (enables linking to embeddings - beginnings of server fuctionality)
|
|
|
|
class COleLinkingDoc : public COleDocument
|
|
{
|
|
DECLARE_DYNAMIC(COleLinkingDoc)
|
|
|
|
// Constructors
|
|
public:
|
|
COleLinkingDoc();
|
|
|
|
// Operations
|
|
BOOL Register(COleObjectFactory* pFactory, const char* pszPathName);
|
|
// notify the running object table and connect to pServer
|
|
void Revoke();
|
|
// revoke from running object table
|
|
|
|
// Overridables
|
|
protected:
|
|
virtual COleServerItem* OnGetLinkedItem(LPCSTR lpszItemName);
|
|
// return item for the named linked item (for supporting links)
|
|
virtual COleClientItem* OnFindEmbeddedItem(LPCSTR lpszItemName);
|
|
// return item for the named embedded item (for links to embeddings)
|
|
|
|
// Implementation
|
|
public:
|
|
COleObjectFactory* m_pFactory; // back-pointer to server
|
|
|
|
#ifdef _DEBUG
|
|
virtual void AssertValid() const;
|
|
virtual void Dump(CDumpContext& dc) const;
|
|
#endif
|
|
virtual ~COleLinkingDoc();
|
|
|
|
// overrides for updating of monikers & running object table registration
|
|
virtual BOOL OnNewDocument();
|
|
virtual BOOL OnOpenDocument(const char* pszPathName);
|
|
virtual BOOL OnSaveDocument(const char* pszPathName);
|
|
virtual void OnCloseDocument();
|
|
virtual LPOLEITEMCONTAINER GetContainer();
|
|
virtual void OnShowViews(BOOL bVisible);
|
|
|
|
protected:
|
|
DWORD m_dwRegister; // file moniker's registration in the ROT
|
|
BOOL m_bVisibleLock; // TRUE if user is holding lock on document
|
|
|
|
// implementation helpers
|
|
void RegisterIfServerAttached(const char* pszPathName);
|
|
void LockExternal(BOOL bLock, BOOL bRemoveRefs);
|
|
void UpdateVisibleLock(BOOL bVisible, BOOL bRemoveRefs);
|
|
|
|
virtual void SaveToStorage(CObject* pObject = NULL);
|
|
|
|
// Interface Maps
|
|
protected:
|
|
BEGIN_INTERFACE_PART(PersistFile, IPersistFile)
|
|
STDMETHOD(GetClassID)(LPCLSID);
|
|
STDMETHOD(IsDirty)();
|
|
STDMETHOD(Load)(LPCSTR, DWORD);
|
|
STDMETHOD(Save)(LPCSTR, BOOL);
|
|
STDMETHOD(SaveCompleted)(LPCSTR);
|
|
STDMETHOD(GetCurFile)(LPSTR FAR*);
|
|
END_INTERFACE_PART(PersistFile)
|
|
|
|
BEGIN_INTERFACE_PART(OleItemContainer, IOleItemContainer)
|
|
STDMETHOD(ParseDisplayName)(LPBC, LPSTR, ULONG FAR*, LPMONIKER FAR*);
|
|
STDMETHOD(EnumObjects)(DWORD, LPENUMUNKNOWN FAR*);
|
|
STDMETHOD(LockContainer)(BOOL);
|
|
STDMETHOD(GetObject)(LPSTR, DWORD, LPBINDCTX, REFIID, LPVOID FAR*);
|
|
STDMETHOD(GetObjectStorage)(LPSTR, LPBINDCTX, REFIID, LPVOID FAR*);
|
|
STDMETHOD(IsRunning)(LPSTR);
|
|
END_INTERFACE_PART(OleItemContainer)
|
|
|
|
DECLARE_INTERFACE_MAP()
|
|
|
|
friend class COleClientItem;
|
|
friend class COleClientItem::XOleClientSite;
|
|
friend class COleServerItem::XOleObject;
|
|
};
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
// COleServerDoc - registered server document containing COleServerItems
|
|
|
|
class COleServerDoc : public COleLinkingDoc
|
|
{
|
|
DECLARE_DYNAMIC(COleServerDoc)
|
|
|
|
// Constructors and Destructors
|
|
public:
|
|
COleServerDoc();
|
|
|
|
// Attributes
|
|
BOOL IsEmbedded() const; // TRUE if document is an embedding
|
|
COleServerItem* GetEmbeddedItem();
|
|
// return embedded item for document (will allocate if necessary)
|
|
|
|
// attributes specific to in-place activation
|
|
BOOL IsInPlaceActive() const;
|
|
void GetItemPosition(LPRECT lpPosRect) const;
|
|
// get current position rectangle of in-place edit
|
|
void GetItemClipRect(LPRECT lpClipRect) const;
|
|
// get current clipping rectangle of in-place edit
|
|
BOOL GetZoomFactor(LPSIZE lpSizeNum = NULL, LPSIZE lpSizeDenom = NULL,
|
|
LPCRECT lpPosRect = NULL) const;
|
|
// returns the zoom factor in pixels
|
|
|
|
// Operations
|
|
void NotifyChanged();
|
|
// call this after you change some global attribute like
|
|
// document dimensions
|
|
void UpdateAllItems(COleServerItem* pSender,
|
|
LPARAM lHint = 0L, CObject* pHint = NULL,
|
|
DVASPECT nDrawAspect = DVASPECT_CONTENT);
|
|
|
|
// changes to the entire document (automatically notifies clients)
|
|
void NotifyRename(LPCSTR lpszNewName);
|
|
void NotifySaved();
|
|
void NotifyClosed(); // call this after you close document
|
|
|
|
// specific operations for embedded documents
|
|
void SaveEmbedding(); // call this to save embedded (before closing)
|
|
|
|
// specific to in-place activation
|
|
BOOL ActivateInPlace();
|
|
void RequestPositionChange(LPCRECT lpPosRect);
|
|
BOOL ScrollContainerBy(CSize sizeScroll);
|
|
BOOL DeactivateAndUndo();
|
|
BOOL DiscardUndoState();
|
|
|
|
public:
|
|
// Overridables for standard user interface (full server)
|
|
virtual BOOL OnUpdateDocument(); // implementation of embedded update
|
|
|
|
protected:
|
|
// Overridables you must implement for yourself
|
|
virtual COleServerItem* OnGetEmbeddedItem() = 0;
|
|
// return item representing entire (embedded) document
|
|
|
|
// Overridables you do not have to implement
|
|
virtual void OnClose(OLECLOSE dwCloseOption);
|
|
virtual void OnSetHostNames(LPCSTR lpszHost, LPCSTR lpszHostObj);
|
|
|
|
// Advanced overridables
|
|
virtual void OnShowDocument(BOOL bShow);
|
|
// show first frame for document or hide all frames for document
|
|
|
|
// Advanced overridables for in-place activation
|
|
virtual void OnDeactivate();
|
|
virtual void OnDeactivateUI(BOOL bUndoable);
|
|
virtual void OnSetItemRects(LPCRECT lpPosRect, LPCRECT lpClipRect);
|
|
virtual BOOL OnReactivateAndUndo();
|
|
|
|
virtual void OnFrameWindowActivate(BOOL bActivate);
|
|
virtual void OnDocWindowActivate(BOOL bActivate);
|
|
virtual void OnShowControlBars(LPOLEINPLACEUIWINDOW lpUIWindow, BOOL bShow);
|
|
virtual void OnResizeBorder(LPCRECT lpRectBorder,
|
|
LPOLEINPLACEUIWINDOW lpUIWindow, BOOL bFrame);
|
|
|
|
virtual COleIPFrameWnd* CreateInPlaceFrame(CWnd* pParentWnd);
|
|
virtual void DestroyInPlaceFrame(COleIPFrameWnd* pFrameWnd);
|
|
|
|
// Implementation
|
|
protected:
|
|
LPOLECLIENTSITE m_lpClientSite; // for embedded item
|
|
CString m_strHostObj; // name of document in container
|
|
BOOL m_bCntrVisible; // TRUE if OnShowWindow(TRUE) called
|
|
BOOL m_bClosing; // TRUE if shutting down
|
|
COleServerItem* m_pEmbeddedItem; // pointer to embedded item for document
|
|
|
|
COleIPFrameWnd* m_pInPlaceFrame; // not NULL if in-place activated
|
|
CWnd* m_pOrigParent; // not NULL if existing view used
|
|
DWORD m_dwOrigStyle; // original style of in-place view
|
|
|
|
public:
|
|
virtual ~COleServerDoc();
|
|
#ifdef _DEBUG
|
|
virtual void AssertValid() const;
|
|
virtual void Dump(CDumpContext& dc) const;
|
|
#endif
|
|
|
|
// overridables for implementation
|
|
virtual BOOL OnSaveDocument(const char* pszPathName);
|
|
virtual void OnCloseDocument();
|
|
virtual void DeleteContents(); // delete auto-delete server items
|
|
virtual LPMONIKER GetMoniker(OLEGETMONIKER nAssign);
|
|
virtual COleServerItem* OnGetLinkedItem(LPCSTR lpszItemName);
|
|
// return item for the named linked item (only if supporting links)
|
|
virtual BOOL CanCloseFrame(CFrameWnd* pFrame);
|
|
|
|
protected:
|
|
// overrides to handle server user-interface
|
|
virtual BOOL SaveModified(); // return TRUE if ok to continue
|
|
virtual HMENU GetDefaultMenu(); // return menu based on doc type
|
|
virtual HACCEL GetDefaultAccelerator(); // return accel table based on doc type
|
|
virtual BOOL GetFileTypeString(CString& rString);
|
|
|
|
// IPersistStorage implementation
|
|
virtual void OnNewEmbedding(LPSTORAGE lpStorage);
|
|
virtual void OnOpenEmbedding(LPSTORAGE lpStorage);
|
|
virtual void OnSaveEmbedding(LPSTORAGE lpStorage);
|
|
|
|
// Implementation helpers
|
|
void NotifyAllItems(OLE_NOTIFICATION wNotification, DWORD dwParam);
|
|
BOOL SaveModifiedPrompt();
|
|
void ConnectView(CWnd* pParentWnd, CView* pView);
|
|
void UpdateUsingHostObj(UINT nIDS, CCmdUI* pCmdUI);
|
|
|
|
// Message Maps
|
|
//{{AFX_MSG(COleServerDoc)
|
|
afx_msg void OnFileUpdate();
|
|
afx_msg void OnFileSaveCopyAs();
|
|
afx_msg void OnUpdateFileUpdate(CCmdUI* pCmdUI);
|
|
afx_msg void OnUpdateFileExit(CCmdUI* pCmdUI);
|
|
//}}AFX_MSG
|
|
DECLARE_MESSAGE_MAP()
|
|
|
|
// Interface Maps
|
|
protected:
|
|
BEGIN_INTERFACE_PART(PersistStorage, IPersistStorage)
|
|
STDMETHOD(GetClassID)(LPCLSID);
|
|
STDMETHOD(IsDirty)();
|
|
STDMETHOD(InitNew)(LPSTORAGE);
|
|
STDMETHOD(Load)(LPSTORAGE);
|
|
STDMETHOD(Save)(LPSTORAGE, BOOL);
|
|
STDMETHOD(SaveCompleted)(LPSTORAGE);
|
|
STDMETHOD(HandsOffStorage)();
|
|
END_INTERFACE_PART(PersistStorage)
|
|
|
|
BEGIN_INTERFACE_PART(OleObject, IOleObject)
|
|
STDMETHOD(SetClientSite)(LPOLECLIENTSITE);
|
|
STDMETHOD(GetClientSite)(LPOLECLIENTSITE FAR*);
|
|
STDMETHOD(SetHostNames)(LPCSTR, LPCSTR);
|
|
STDMETHOD(Close)(DWORD);
|
|
STDMETHOD(SetMoniker)(DWORD, LPMONIKER);
|
|
STDMETHOD(GetMoniker)(DWORD, DWORD, LPMONIKER FAR*);
|
|
STDMETHOD(InitFromData)(LPDATAOBJECT, BOOL, DWORD);
|
|
STDMETHOD(GetClipboardData)(DWORD, LPDATAOBJECT FAR*);
|
|
STDMETHOD(DoVerb)(LONG, LPMSG, LPOLECLIENTSITE, LONG, HWND, LPCRECT);
|
|
STDMETHOD(EnumVerbs)(IEnumOLEVERB FAR* FAR*);
|
|
STDMETHOD(Update)();
|
|
STDMETHOD(IsUpToDate)();
|
|
STDMETHOD(GetUserClassID)(CLSID FAR*);
|
|
STDMETHOD(GetUserType)(DWORD, LPSTR FAR*);
|
|
STDMETHOD(SetExtent)(DWORD, LPSIZEL);
|
|
STDMETHOD(GetExtent)(DWORD, LPSIZEL);
|
|
STDMETHOD(Advise)(LPADVISESINK, LPDWORD);
|
|
STDMETHOD(Unadvise)(DWORD);
|
|
STDMETHOD(EnumAdvise)(LPENUMSTATDATA FAR*);
|
|
STDMETHOD(GetMiscStatus)(DWORD, LPDWORD);
|
|
STDMETHOD(SetColorScheme)(LPLOGPALETTE);
|
|
END_INTERFACE_PART(OleObject)
|
|
|
|
BEGIN_INTERFACE_PART(DataObject, IDataObject)
|
|
STDMETHOD(GetData)(LPFORMATETC, LPSTGMEDIUM);
|
|
STDMETHOD(GetDataHere)(LPFORMATETC, LPSTGMEDIUM);
|
|
STDMETHOD(QueryGetData)(LPFORMATETC);
|
|
STDMETHOD(GetCanonicalFormatEtc)(LPFORMATETC, LPFORMATETC);
|
|
STDMETHOD(SetData)(LPFORMATETC, LPSTGMEDIUM, BOOL);
|
|
STDMETHOD(EnumFormatEtc)(DWORD, LPENUMFORMATETC FAR*);
|
|
STDMETHOD(DAdvise)(LPFORMATETC, DWORD, LPADVISESINK, LPDWORD);
|
|
STDMETHOD(DUnadvise)(DWORD);
|
|
STDMETHOD(EnumDAdvise)(LPENUMSTATDATA FAR*);
|
|
END_INTERFACE_PART(DataObject)
|
|
|
|
BEGIN_INTERFACE_PART(OleInPlaceObject, IOleInPlaceObject)
|
|
STDMETHOD(GetWindow)(HWND FAR*);
|
|
STDMETHOD(ContextSensitiveHelp)(BOOL);
|
|
STDMETHOD(InPlaceDeactivate)();
|
|
STDMETHOD(UIDeactivate)();
|
|
STDMETHOD(SetObjectRects)(LPCRECT, LPCRECT);
|
|
STDMETHOD(ReactivateAndUndo)();
|
|
END_INTERFACE_PART(OleInPlaceObject)
|
|
|
|
BEGIN_INTERFACE_PART(OleInPlaceActiveObject, IOleInPlaceActiveObject)
|
|
STDMETHOD(GetWindow)(HWND FAR*);
|
|
STDMETHOD(ContextSensitiveHelp)(BOOL);
|
|
STDMETHOD(TranslateAccelerator)(LPMSG);
|
|
STDMETHOD(OnFrameWindowActivate)(BOOL);
|
|
STDMETHOD(OnDocWindowActivate)(BOOL);
|
|
STDMETHOD(ResizeBorder)(LPCRECT, LPOLEINPLACEUIWINDOW, BOOL);
|
|
STDMETHOD(EnableModeless)(BOOL);
|
|
END_INTERFACE_PART(OleInPlaceActiveObject)
|
|
|
|
DECLARE_INTERFACE_MAP()
|
|
|
|
friend class COleServer;
|
|
friend class COleServerItem;
|
|
};
|
|
|
|
//////////////////////////////////////////////////////////////////////////////
|
|
// COleIPFrameWnd
|
|
|
|
class COleIPFrameWnd : public CFrameWnd
|
|
{
|
|
DECLARE_DYNCREATE(COleIPFrameWnd)
|
|
|
|
// Constructors
|
|
public:
|
|
COleIPFrameWnd();
|
|
|
|
// Overridables
|
|
public:
|
|
virtual BOOL OnCreateControlBars(CWnd* pWndFrame, CWnd* pWndDoc);
|
|
// create control bars on container windows (pWndDoc can be NULL)
|
|
void RepositionFrame(LPCRECT lpPosRect, LPCRECT lpClipRect);
|
|
|
|
// Implementation
|
|
public:
|
|
BOOL m_bUIActive; // TRUE if currently in uiacitve state
|
|
|
|
virtual BOOL LoadFrame(UINT nIDResource,
|
|
DWORD dwDefaultStyle = WS_CHILD|WS_BORDER|WS_CLIPSIBLINGS,
|
|
CWnd* pParentWnd = NULL,
|
|
CCreateContext* pContext = NULL);
|
|
virtual void RecalcLayout(BOOL bNotify = TRUE);
|
|
virtual BOOL PreTranslateMessage(MSG* pMsg);
|
|
virtual LRESULT OnSetMessageString(WPARAM wParam, LPARAM lParam);
|
|
virtual ~COleIPFrameWnd();
|
|
#ifdef _DEBUG
|
|
virtual void AssertValid() const;
|
|
virtual void Dump(CDumpContext& dc) const;
|
|
#endif
|
|
|
|
protected:
|
|
// in-place state
|
|
OLEINPLACEFRAMEINFO m_frameInfo;
|
|
LPOLEINPLACEFRAME m_lpFrame;
|
|
LPOLEINPLACEUIWINDOW m_lpDocFrame;
|
|
HWND m_hWndFrame;
|
|
HWND m_hWndDocFrame;
|
|
HMENU m_hSharedMenu;
|
|
OLEMENUGROUPWIDTHS m_menuWidths;
|
|
HOLEMENU m_hOleMenu;
|
|
CRect m_rectPos; // client area rect of the item
|
|
CRect m_rectClip; // area to which frame should be clipped
|
|
BOOL m_bInsideRecalc;
|
|
|
|
// in-place activation support
|
|
BOOL BuildSharedMenu(COleServerDoc* pDoc);
|
|
void DestroySharedMenu(COleServerDoc* pDoc);
|
|
void UpdateControlBars(HWND hWnd);
|
|
|
|
protected:
|
|
//{{AFX_MSG(COleIPFrameWnd)
|
|
afx_msg void OnSize(UINT nType, int cx, int cy);
|
|
afx_msg LRESULT OnRecalcParent(WPARAM wParam, LPARAM lParam);
|
|
afx_msg LRESULT OnIdleUpdateCmdUI(WPARAM wParam, LPARAM lParam);
|
|
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
|
|
afx_msg void OnDestroy();
|
|
afx_msg LRESULT OnResizeChild(WPARAM wParam, LPARAM lParam);
|
|
afx_msg void OnContextHelp();
|
|
//}}AFX_MSG
|
|
DECLARE_MESSAGE_MAP()
|
|
|
|
friend class COleServerDoc;
|
|
};
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// COleResizeBar - supports in-place resizing in server applications
|
|
|
|
class COleResizeBar : public CControlBar
|
|
{
|
|
DECLARE_DYNAMIC(COleResizeBar)
|
|
|
|
// Constructors
|
|
public:
|
|
COleResizeBar();
|
|
BOOL Create(CWnd* pParentWnd, DWORD dwStyle = WS_CHILD | WS_VISIBLE,
|
|
UINT nID = AFX_IDW_RESIZE_BAR);
|
|
|
|
// Implementation
|
|
public:
|
|
virtual ~COleResizeBar();
|
|
virtual void OnUpdateCmdUI(CFrameWnd* pTarget, BOOL bDisableIfNoHndler);
|
|
|
|
protected:
|
|
CRectTracker m_tracker; // implemented with a tracker
|
|
|
|
protected:
|
|
//{{AFX_MSG(COleResizeBar)
|
|
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
|
|
afx_msg void OnPaint();
|
|
afx_msg void OnSize(UINT nType, int cx, int cy);
|
|
afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
|
|
afx_msg void OnLButtonDown(UINT, CPoint point);
|
|
afx_msg LRESULT OnSizeParent(WPARAM wParam, LPARAM lParam);
|
|
//}}AFX_MSG
|
|
DECLARE_MESSAGE_MAP()
|
|
};
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// COleStreamFile - implementation of CFile which uses an IStream
|
|
|
|
class COleStreamFile : public CFile
|
|
{
|
|
DECLARE_DYNAMIC(COleStreamFile)
|
|
|
|
// Constructors and Destructors
|
|
public:
|
|
COleStreamFile(LPSTREAM lpStream = NULL);
|
|
|
|
// Operations
|
|
// Note: OpenStream and CreateStream can accept eith STGM_ flags or
|
|
// CFile::OpenFlags bits since common values are guaranteed to have
|
|
// the same semantics.
|
|
BOOL OpenStream(LPSTORAGE lpStorage, LPCSTR lpszStreamName,
|
|
DWORD nOpenFlags = modeReadWrite|shareExclusive,
|
|
CFileException* pError = NULL);
|
|
BOOL CreateStream(LPSTORAGE lpStorage, LPCSTR lpszStreamName,
|
|
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();
|
|
|
|
// 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;
|
|
|
|
// 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 FAR* lpBuf, UINT nCount);
|
|
virtual void Write(const void FAR* 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();
|
|
};
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// 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
|
|
|
|
protected:
|
|
BEGIN_INTERFACE_PART(DropSource, IDropSource)
|
|
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?
|
|
|
|
// metrics for drag start determination
|
|
static UINT nDragMinDist; // min. amount mouse must move for drag
|
|
static 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 void OnDragLeave(CWnd* pWnd);
|
|
virtual BOOL 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 int nScrollInset;
|
|
static UINT nScrollDelay;
|
|
static UINT nScrollInterval;
|
|
|
|
// implementation helpers
|
|
void SetupTimer(CView* pView, UINT nTimerID);
|
|
void CancelTimer(CWnd* pWnd);
|
|
|
|
// Interface Maps
|
|
protected:
|
|
BEGIN_INTERFACE_PART(DropTarget, IDropTarget)
|
|
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 IsSignificantMessage(MSG* pMsg);
|
|
// determine if any significant messages are present in the queue
|
|
virtual int OnBusyDialog(HTASK htaskBusy);
|
|
virtual int OnNotRespondingDialog(HTASK htaskBusy);
|
|
// these functions display the busy dialog
|
|
|
|
protected:
|
|
BOOL m_bRegistered;
|
|
LONG m_nBusyCount; // for BeginBusyState & EndBusyState
|
|
BOOL m_bEnableBusy;
|
|
BOOL m_bEnableNotResponding;
|
|
BOOL m_bUnblocking;
|
|
DWORD m_nRetryReply; // only used if m_bEnableNotResponding == FALSE
|
|
DWORD m_nBusyReply;
|
|
DWORD m_nTimeout;
|
|
|
|
// Interface Maps
|
|
protected:
|
|
BEGIN_INTERFACE_PART(MessageFilter, IMessageFilter)
|
|
STDMETHOD_(DWORD, HandleInComingCall)(DWORD, HTASK, DWORD, DWORD);
|
|
STDMETHOD_(DWORD, RetryRejectedCall)(HTASK, DWORD, DWORD);
|
|
STDMETHOD_(DWORD, MessagePending)(HTASK, DWORD, DWORD);
|
|
END_INTERFACE_PART(MessageFilter)
|
|
|
|
DECLARE_INTERFACE_MAP()
|
|
};
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// global helpers and debugging
|
|
|
|
void AFXAPI AfxOleSetEditMenu(COleClientItem* pClient, CMenu* pMenu,
|
|
UINT iMenuItem, UINT nIDVerbMin, UINT nIDVerbMax = 0, UINT nIDConvert = 0);
|
|
|
|
#ifdef _DEBUG
|
|
// Mapping SCODEs to readable text
|
|
LPCSTR AFXAPI AfxGetFullScodeString(SCODE sc);
|
|
LPCSTR AFXAPI AfxGetScodeString(SCODE sc);
|
|
LPCSTR AFXAPI AfxGetScodeRangeString(SCODE sc);
|
|
LPCSTR AFXAPI AfxGetSeverityString(SCODE sc);
|
|
LPCSTR AFXAPI AfxGetFacilityString(SCODE sc);
|
|
|
|
// Mapping IIDs to readable text
|
|
LPCSTR AFXAPI AfxGetIIDString(REFIID iid);
|
|
#endif
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// Inline function declarations
|
|
|
|
#ifdef _AFX_ENABLE_INLINES
|
|
#ifndef _AFXCTL
|
|
#define _AFXOLE_INLINE inline
|
|
#define _AFXOLECLI_INLINE inline
|
|
#define _AFXOLESVR_INLINE inline
|
|
#endif
|
|
#define _AFXOLEDOBJ_INLINE inline
|
|
#include <afxole.inl>
|
|
#undef _AFXOLE_INLINE
|
|
#undef _AFXOLECLI_INLINE
|
|
#undef _AFXOLESVR_INLINE
|
|
#undef _AFXOLEDOBJ_INLINE
|
|
#endif
|
|
|
|
#undef AFXAPP_DATA
|
|
#define AFXAPP_DATA NEAR
|
|
|
|
#endif //__AFXOLE_H__
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|