📄 afxdisp.h
字号:
#else
#define BEGIN_CONNECTION_MAP(theClass, theBase) \
const AFX_CONNECTIONMAP* theClass::GetConnectionMap() const \
{ return &theClass::connectionMap; } \
AFX_COMDAT const AFX_DATADEF AFX_CONNECTIONMAP theClass::connectionMap = \
{ &(theBase::connectionMap), &theClass::_connectionEntries[0], }; \
AFX_COMDAT const AFX_DATADEF AFX_CONNECTIONMAP_ENTRY theClass::_connectionEntries[] = \
{ \
#endif
#define CONNECTION_PART(theClass, iid, localClass) \
{ &iid, offsetof(theClass, m_x##localClass) }, \
#define END_CONNECTION_MAP() \
{ NULL, (size_t)-1 } \
}; \
/////////////////////////////////////////////////////////////////////////////
// CConnectionPoint
#ifdef _AFXDLL
class CConnectionPoint : public CCmdTarget
#else
class AFX_NOVTABLE CConnectionPoint : public CCmdTarget
#endif
{
// Constructors
public:
CConnectionPoint();
// Operations
POSITION GetStartPosition() const;
LPUNKNOWN GetNextConnection(POSITION& pos) const;
const CPtrArray* GetConnections(); // obsolete
// Overridables
virtual LPCONNECTIONPOINTCONTAINER GetContainer();
virtual REFIID GetIID() = 0;
virtual void OnAdvise(BOOL bAdvise);
virtual int GetMaxConnections();
virtual LPUNKNOWN QuerySinkInterface(LPUNKNOWN pUnkSink);
// Implementation
~CConnectionPoint();
void CreateConnectionArray();
int GetConnectionCount();
protected:
size_t m_nOffset;
LPUNKNOWN m_pUnkFirstConnection;
CPtrArray* m_pConnections;
// Interface Maps
public:
BEGIN_INTERFACE_PART(ConnPt, IConnectionPoint)
INIT_INTERFACE_PART(CConnectionPoint, ConnPt)
STDMETHOD(GetConnectionInterface)(IID* pIID);
STDMETHOD(GetConnectionPointContainer)(
IConnectionPointContainer** ppCPC);
STDMETHOD(Advise)(LPUNKNOWN pUnkSink, DWORD* pdwCookie);
STDMETHOD(Unadvise)(DWORD dwCookie);
STDMETHOD(EnumConnections)(LPENUMCONNECTIONS* ppEnum);
END_INTERFACE_PART(ConnPt)
};
/////////////////////////////////////////////////////////////////////////////
// EventSink Maps
#ifndef _AFX_NO_OCC_SUPPORT
#ifdef _AFXDLL
#define BEGIN_EVENTSINK_MAP(theClass, baseClass) \
const AFX_EVENTSINKMAP* PASCAL theClass::_GetBaseEventSinkMap() \
{ return &baseClass::eventsinkMap; } \
const AFX_EVENTSINKMAP* theClass::GetEventSinkMap() const \
{ return &theClass::eventsinkMap; } \
const AFX_EVENTSINKMAP theClass::eventsinkMap = \
{ &theClass::_GetBaseEventSinkMap, &theClass::_eventsinkEntries[0], \
&theClass::_eventsinkEntryCount }; \
UINT theClass::_eventsinkEntryCount = (UINT)-1; \
const AFX_EVENTSINKMAP_ENTRY theClass::_eventsinkEntries[] = \
{ \
#else
#define BEGIN_EVENTSINK_MAP(theClass, baseClass) \
const AFX_EVENTSINKMAP* theClass::GetEventSinkMap() const \
{ return &theClass::eventsinkMap; } \
const AFX_EVENTSINKMAP theClass::eventsinkMap = \
{ &baseClass::eventsinkMap, &theClass::_eventsinkEntries[0], \
&theClass::_eventsinkEntryCount }; \
UINT theClass::_eventsinkEntryCount = (UINT)-1; \
const AFX_EVENTSINKMAP_ENTRY theClass::_eventsinkEntries[] = \
{ \
#endif
#define END_EVENTSINK_MAP() \
{ VTS_NONE, DISPID_UNKNOWN, VTS_NONE, VT_VOID, \
(AFX_PMSG)NULL, (AFX_PMSG)NULL, (size_t)-1, afxDispCustom, \
(UINT)-1, 0 } }; \
#define ON_EVENT(theClass, id, dispid, pfnHandler, vtsParams) \
{ _T(""), dispid, vtsParams, VT_BOOL, \
(AFX_PMSG)(void (theClass::*)(void))&pfnHandler, (AFX_PMSG)0, 0, \
afxDispCustom, id, (UINT)-1 }, \
#define ON_EVENT_RANGE(theClass, idFirst, idLast, dispid, pfnHandler, vtsParams) \
{ _T(""), dispid, vtsParams, VT_BOOL, \
(AFX_PMSG)(void (theClass::*)(void))&pfnHandler, (AFX_PMSG)0, 0, \
afxDispCustom, idFirst, idLast }, \
#define ON_PROPNOTIFY(theClass, id, dispid, pfnRequest, pfnChanged) \
{ _T(""), dispid, VTS_NONE, VT_VOID, \
(AFX_PMSG)(BOOL (CCmdTarget::*)(BOOL*))&pfnRequest, \
(AFX_PMSG)(BOOL (CCmdTarget::*)(void))&pfnChanged, \
1, afxDispCustom, id, (UINT)-1 }, \
#define ON_PROPNOTIFY_RANGE(theClass, idFirst, idLast, dispid, pfnRequest, pfnChanged) \
{ _T(""), dispid, VTS_NONE, VT_VOID, \
(AFX_PMSG)(BOOL (CCmdTarget::*)(UINT, BOOL*))&pfnRequest, \
(AFX_PMSG)(BOOL (CCmdTarget::*)(UINT))&pfnChanged, \
1, afxDispCustom, idFirst, idLast }, \
#define ON_DSCNOTIFY(theClass, id, pfnNotify) \
{ _T(""), DISPID_UNKNOWN, VTS_NONE, VT_VOID, \
(AFX_PMSG)(BOOL (CCmdTarget::*)(DSCSTATE, DSCREASON, BOOL*))&pfnNotify, (AFX_PMSG)0, \
1, afxDispCustom, id, (UINT)-1 }, \
#define ON_DSCNOTIFY_RANGE(theClass, idFirst, idLast, pfnNotify) \
{ _T(""), DISPID_UNKNOWN, VTS_NONE, VT_VOID, \
(AFX_PMSG)(BOOL (CCmdTarget::*)(UINT, DSCSTATE, DSCREASON, BOOL*))&pfnNotify, (AFX_PMSG)0, \
1, afxDispCustom, idFirst, idLast }, \
#define ON_EVENT_REFLECT(theClass, dispid, pfnHandler, vtsParams) \
{ _T(""), dispid, vtsParams, VT_BOOL, \
(AFX_PMSG)(void (theClass::*)(void))&pfnHandler, (AFX_PMSG)0, 0, \
afxDispCustom, (UINT)-1, (UINT)-1 }, \
#define ON_PROPNOTIFY_REFLECT(theClass, dispid, pfnRequest, pfnChanged) \
{ _T(""), dispid, VTS_NONE, VT_VOID, \
(AFX_PMSG)(BOOL (CCmdTarget::*)(BOOL*))&pfnRequest, \
(AFX_PMSG)(BOOL (CCmdTarget::*)(void))&pfnChanged, \
1, afxDispCustom, (UINT)-1, (UINT)-1 }, \
#endif // !_AFX_NO_OCC_SUPPORT
/////////////////////////////////////////////////////////////////////////////
// Macros for type library information
CTypeLibCache* AFXAPI AfxGetTypeLibCache(const GUID* pTypeLibID);
#define DECLARE_OLETYPELIB(class_name) \
protected: \
virtual UINT GetTypeInfoCount(); \
virtual HRESULT GetTypeLib(LCID, LPTYPELIB*); \
virtual CTypeLibCache* GetTypeLibCache(); \
#define IMPLEMENT_OLETYPELIB(class_name, tlid, wVerMajor, wVerMinor) \
UINT class_name::GetTypeInfoCount() \
{ return 1; } \
HRESULT class_name::GetTypeLib(LCID lcid, LPTYPELIB* ppTypeLib) \
{ return ::LoadRegTypeLib(tlid, wVerMajor, wVerMinor, lcid, ppTypeLib); } \
CTypeLibCache* class_name::GetTypeLibCache() \
{ AFX_MANAGE_STATE(m_pModuleState); return AfxGetTypeLibCache(&tlid); } \
/////////////////////////////////////////////////////////////////////////////
// Init & Term helpers
BOOL AFXAPI AfxOleInit();
void AFXAPI AfxOleTerm(BOOL bJustRevoke = FALSE);
void AFXAPI AfxOleTermOrFreeLib(BOOL bTerm = TRUE, BOOL bJustRevoke = FALSE);
/////////////////////////////////////////////////////////////////////////////
// Memory management helpers (for OLE task allocator memory)
#define AfxAllocTaskMem(nSize) CoTaskMemAlloc(nSize)
#define AfxFreeTaskMem(p) CoTaskMemFree(p)
LPWSTR AFXAPI AfxAllocTaskWideString(LPCWSTR lpszString);
LPWSTR AFXAPI AfxAllocTaskWideString(LPCSTR lpszString);
LPSTR AFXAPI AfxAllocTaskAnsiString(LPCWSTR lpszString);
LPSTR AFXAPI AfxAllocTaskAnsiString(LPCSTR lpszString);
#ifdef _UNICODE
#define AfxAllocTaskString(x) AfxAllocTaskWideString(x)
#else
#define AfxAllocTaskString(x) AfxAllocTaskAnsiString(x)
#endif
#ifdef OLE2ANSI
#define AfxAllocTaskOleString(x) AfxAllocTaskAnsiString(x)
#else
#define AfxAllocTaskOleString(x) AfxAllocTaskWideString(x)
#endif
HRESULT AFXAPI AfxGetClassIDFromString(LPCTSTR lpsz, LPCLSID lpClsID);
/////////////////////////////////////////////////////////////////////////////
// Special in-proc server APIs
SCODE AFXAPI AfxDllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv);
SCODE AFXAPI AfxDllCanUnloadNow(void);
/////////////////////////////////////////////////////////////////////////////
// COleVariant class helpers
#define AFX_OLE_TRUE (-1)
#define AFX_OLE_FALSE 0
class CLongBinary; // forward reference (see afxdb_.h)
/////////////////////////////////////////////////////////////////////////////
// COleVariant class - wraps VARIANT types
typedef const VARIANT* LPCVARIANT;
class COleVariant : public tagVARIANT
{
// Constructors
public:
COleVariant();
COleVariant(const VARIANT& varSrc);
COleVariant(LPCVARIANT pSrc);
COleVariant(const COleVariant& varSrc);
COleVariant(LPCTSTR lpszSrc);
COleVariant(LPCTSTR lpszSrc, VARTYPE vtSrc); // used to set to ANSI string
COleVariant(CString& strSrc);
COleVariant(BYTE nSrc);
COleVariant(short nSrc, VARTYPE vtSrc = VT_I2);
COleVariant(long lSrc, VARTYPE vtSrc = VT_I4);
COleVariant(const COleCurrency& curSrc);
COleVariant(float fltSrc);
COleVariant(double dblSrc);
COleVariant(const COleDateTime& timeSrc);
COleVariant(const CByteArray& arrSrc);
COleVariant(const CLongBinary& lbSrc);
COleVariant(LPCITEMIDLIST pidl);
// Operations
public:
void Clear();
void ChangeType(VARTYPE vartype, LPVARIANT pSrc = NULL);
void Attach(VARIANT& varSrc);
VARIANT Detach();
BOOL operator==(const VARIANT& varSrc) const;
BOOL operator==(LPCVARIANT pSrc) const;
const COleVariant& operator=(const VARIANT& varSrc);
const COleVariant& operator=(LPCVARIANT pSrc);
const COleVariant& operator=(const COleVariant& varSrc);
const COleVariant& operator=(const LPCTSTR lpszSrc);
const COleVariant& operator=(const CString& strSrc);
const COleVariant& operator=(BYTE nSrc);
const COleVariant& operator=(short nSrc);
const COleVariant& operator=(long lSrc);
const COleVariant& operator=(const COleCurrency& curSrc);
const COleVariant& operator=(float fltSrc);
const COleVariant& operator=(double dblSrc);
const COleVariant& operator=(const COleDateTime& dateSrc);
const COleVariant& operator=(const CByteArray& arrSrc);
const COleVariant& operator=(const CLongBinary& lbSrc);
void SetString(LPCTSTR lpszSrc, VARTYPE vtSrc); // used to set ANSI string
operator LPVARIANT();
operator LPCVARIANT() const;
// Implementation
public:
~COleVariant();
void _ClearCompat();
};
// COleVariant diagnostics and serialization
#ifdef _DEBUG
CDumpContext& AFXAPI operator<<(CDumpContext& dc, COleVariant varSrc);
#endif
CArchive& AFXAPI operator<<(CArchive& ar, COleVariant varSrc);
CArchive& AFXAPI operator>>(CArchive& ar, COleVariant& varSrc);
// Helper for initializing VARIANT structures
void AFXAPI AfxVariantInit(LPVARIANT pVar);
/////////////////////////////////////////////////////////////////////////////
// COleCurrency class
class COleCurrency
{
// Constructors
public:
COleCurrency();
COleCurrency(CURRENCY cySrc);
COleCurrency(const COleCurrency& curSrc);
COleCurrency(const VARIANT& varSrc);
COleCurrency(long nUnits, long nFractionalUnits);
// Attributes
public:
enum CurrencyStatus
{
valid = 0,
invalid = 1, // Invalid currency (overflow, div 0, etc.)
null = 2, // Literally has no value
};
CURRENCY m_cur;
CurrencyStatus m_status;
void SetStatus(CurrencyStatus status);
CurrencyStatus GetStatus() const;
// Operations
public:
const COleCurrency& operator=(CURRENCY cySrc);
const COleCurrency& operator=(const COleCurrency& curSrc);
const COleCurrency& operator=(const VARIANT& varSrc);
BOOL operator==(const COleCurrency& cur) const;
BOOL operator!=(const COleCurrency& cur) const;
BOOL operator<(const COleCurrency& cur) const;
BOOL operator>(const COleCurrency& cur) const;
BOOL operator<=(const COleCurrency& cur) const;
BOOL operator>=(const COleCurrency& cur) const;
// Currency math
COleCurrency operator+(const COleCurrency& cur) const;
COleCurrency operator-(const COleCurrency& cur) const;
const COleCurrency& operator+=(const COleCurrency& cur);
const COleCurrency& operator-=(const COleCurrency& cur);
COleCurrency operator-() const;
COleCurrency operator*(long nOperand) const;
COleCurrency operator/(long nOperand) const;
const COleCurrency& operator*=(long nOperand);
const COleCurrency& operator/=(long nOperand);
operator CURRENCY() const;
// Currency definition
void SetCurrency(long nUnits, long nFractionalUnits);
BOOL ParseCurrency(LPCTSTR lpszCurrency, DWORD dwFlags = 0,
LCID = LANG_USER_DEFAULT);
// formatting
CString Format(DWORD dwFlags = 0, LCID lcid = LANG_USER_DEFAULT) const;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -