Annotation of sql/odbc/MFCpatches/oleimpl2.h, revision 1.1
1.1 ! paf 1: // Note: Must include AFXOLE.H first
! 2:
! 3: #if _MSC_VER > 1000
! 4: #pragma once
! 5: #endif
! 6:
! 7: #undef AFX_DATA
! 8: #define AFX_DATA AFX_OLE_DATA
! 9:
! 10: /////////////////////////////////////////////////////////////////////////////
! 11: // COleFrameHook - AFX_INTERNAL
! 12:
! 13: class COleFrameHook : public CCmdTarget
! 14: {
! 15: // Construction & Destruction
! 16: public:
! 17: COleFrameHook(CFrameWnd* pFrameWnd, COleClientItem* pItem);
! 18:
! 19: // Implementation
! 20: public:
! 21: ~COleFrameHook();
! 22:
! 23: CFrameWnd* m_pFrameWnd;
! 24: LPOLEINPLACEACTIVEOBJECT m_lpActiveObject;
! 25: COleClientItem* m_pActiveItem; // item this COleFrameHook is for
! 26: HWND m_hWnd; // actual HWND this hook is attached to
! 27: BOOL m_bInModalState; // TRUE if EnableModeless(FALSE) has been called
! 28: BOOL m_bToolBarHidden; // TRUE if toolbar needs to be shown OnUIDeactivate
! 29: HACCEL m_hAccelTable; // accelerator to be used while in-place object active
! 30: UINT m_nModelessCount; // !0 if server's EnableModeless has been called
! 31: CString m_strObjName; // name of the active in-place object
! 32:
! 33: // Overrides for implementation
! 34: public:
! 35: virtual void OnRecalcLayout(); // for border space re-negotiation
! 36: virtual BOOL OnPreTranslateMessage(MSG* pMsg);
! 37: virtual void OnActivate(BOOL bActive); // for OnFrameWindowActivate
! 38: virtual BOOL OnDocActivate(BOOL bActive); // for OnDocWindowActivate
! 39: virtual BOOL OnContextHelp(BOOL bEnter);
! 40: virtual void OnEnableModeless(BOOL bEnable);
! 41: virtual BOOL OnUpdateFrameTitle();
! 42: virtual void OnPaletteChanged(CWnd* pFocusWnd);
! 43: virtual BOOL OnQueryNewPalette();
! 44: virtual BOOL OnInitMenuPopup(CMenu* pMenu, int nIndex, BOOL bSysMenu);
! 45: virtual void OnInitMenu(CMenu* pMenu);
! 46: virtual BOOL OnMenuSelect(UINT nItemID, UINT nFlags, HMENU hSysMenu);
! 47:
! 48: // implementation helpers
! 49: BOOL NotifyAllInPlace(
! 50: BOOL bParam, BOOL (COleFrameHook::*pNotifyFunc)(BOOL bParam));
! 51: BOOL DoContextSensitiveHelp(BOOL bEnter);
! 52: BOOL DoEnableModeless(BOOL bEnable);
! 53:
! 54: // Interface Maps
! 55: public:
! 56: BEGIN_INTERFACE_PART(OleInPlaceFrame, IOleInPlaceFrame)
! 57: INIT_INTERFACE_PART(COleFrameHook, OleInPlaceFrame)
! 58: STDMETHOD(GetWindow)(HWND*);
! 59: STDMETHOD(ContextSensitiveHelp)(BOOL);
! 60: STDMETHOD(GetBorder)(LPRECT);
! 61: STDMETHOD(RequestBorderSpace)(LPCBORDERWIDTHS);
! 62: STDMETHOD(SetBorderSpace)(LPCBORDERWIDTHS);
! 63: STDMETHOD(SetActiveObject)(LPOLEINPLACEACTIVEOBJECT, LPCOLESTR);
! 64: STDMETHOD(InsertMenus)(HMENU, LPOLEMENUGROUPWIDTHS);
! 65: STDMETHOD(SetMenu)(HMENU, HOLEMENU, HWND);
! 66: STDMETHOD(RemoveMenus)(HMENU);
! 67: STDMETHOD(SetStatusText)(LPCOLESTR);
! 68: STDMETHOD(EnableModeless)(BOOL);
! 69: STDMETHOD(TranslateAccelerator)(LPMSG, WORD);
! 70: END_INTERFACE_PART(OleInPlaceFrame)
! 71:
! 72: //WINBUG: this interface is here because some applications
! 73: // are broken and require IOleCommandTarget to be
! 74: // implemented before they'll properly activate
! 75: BEGIN_INTERFACE_PART(OleCommandTarget, IOleCommandTarget)
! 76: INIT_INTERFACE_PART(COleFrameHook, OleCommandTarget)
! 77: STDMETHOD(Exec)(const GUID*, DWORD, DWORD,
! 78: VARIANTARG*, VARIANTARG*);
! 79: STDMETHOD(QueryStatus)(const GUID*, ULONG, OLECMD foo[], OLECMDTEXT*);
! 80: END_INTERFACE_PART(OleCommandTarget)
! 81:
! 82: DECLARE_INTERFACE_MAP()
! 83:
! 84: friend COleClientItem;
! 85: };
! 86:
! 87: /////////////////////////////////////////////////////////////////////////////
! 88: // Helper for implementing OLE enumerators
! 89:
! 90: // Note: the following interface is not an actual OLE interface, but is useful
! 91: // for describing an abstract (not typesafe) enumerator.
! 92:
! 93: #undef INTERFACE
! 94: #define INTERFACE IEnumVOID
! 95:
! 96: DECLARE_INTERFACE_(IEnumVOID, IUnknown)
! 97: {
! 98: STDMETHOD(QueryInterface)(REFIID, LPVOID*) PURE;
! 99: STDMETHOD_(ULONG,AddRef)() PURE;
! 100: STDMETHOD_(ULONG,Release)() PURE;
! 101: STDMETHOD(Next)(ULONG, void*, ULONG*) PURE;
! 102: STDMETHOD(Skip)(ULONG) PURE;
! 103: STDMETHOD(Reset)() PURE;
! 104: STDMETHOD(Clone)(IEnumVOID**) PURE;
! 105: };
! 106:
! 107: class CEnumArray : public CCmdTarget
! 108: {
! 109: // Constructors
! 110: public:
! 111: CEnumArray(size_t nSize,
! 112: const void* pvEnum, UINT nCount, BOOL bNeedFree = FALSE);
! 113:
! 114: // Implementation
! 115: public:
! 116: virtual ~CEnumArray();
! 117:
! 118: protected:
! 119: size_t m_nSizeElem; // size of each item in the array
! 120: CCmdTarget* m_pClonedFrom; // used to keep original alive for clones
! 121:
! 122: BYTE* m_pvEnum; // pointer data to enumerate
! 123: UINT m_nCurPos; // current position in m_pvEnum
! 124: UINT m_nSize; // total number of items in m_pvEnum
! 125: BOOL m_bNeedFree; // free on release?
! 126:
! 127: virtual BOOL OnNext(void* pv);
! 128: virtual BOOL OnSkip();
! 129: virtual void OnReset();
! 130: virtual CEnumArray* OnClone();
! 131:
! 132: // Interface Maps
! 133: public:
! 134: BEGIN_INTERFACE_PART(EnumVOID, IEnumVOID)
! 135: INIT_INTERFACE_PART(CEnumArray, EnumVOID)
! 136: STDMETHOD(Next)(ULONG, void*, ULONG*);
! 137: STDMETHOD(Skip)(ULONG);
! 138: STDMETHOD(Reset)();
! 139: STDMETHOD(Clone)(IEnumVOID**);
! 140: END_INTERFACE_PART(EnumVOID)
! 141: };
! 142:
! 143: /////////////////////////////////////////////////////////////////////////////
! 144: // COleDispatchImpl - IDispatch implementation
! 145:
! 146: // Note: This class is only designed to be used as a CCmdTarget member
! 147: // (at the offset specified by CCmdTarget::m_xDispatch))
! 148: // It WILL NOT work in other classes or at different offsets!
! 149:
! 150: class COleDispatchImpl : public IDispatch
! 151: {
! 152: public:
! 153: #ifndef _AFX_NO_NESTED_DERIVATION
! 154: // required for METHOD_PROLOGUE_EX
! 155: size_t m_nOffset;
! 156: COleDispatchImpl::COleDispatchImpl()
! 157: { m_nOffset = offsetof(CCmdTarget, m_xDispatch); }
! 158: #endif
! 159:
! 160: STDMETHOD_(ULONG, AddRef)();
! 161: STDMETHOD_(ULONG, Release)();
! 162: STDMETHOD(QueryInterface)(REFIID, LPVOID*);
! 163:
! 164: STDMETHOD(GetTypeInfoCount)(UINT*);
! 165: STDMETHOD(GetTypeInfo)(UINT, LCID, LPTYPEINFO*);
! 166: STDMETHOD(GetIDsOfNames)(REFIID, LPOLESTR*, UINT, LCID, DISPID*);
! 167: STDMETHOD(Invoke)(DISPID, REFIID, LCID, WORD, DISPPARAMS*, LPVARIANT,
! 168: LPEXCEPINFO, UINT*);
! 169:
! 170: // special method for disconnect
! 171: virtual void Disconnect();
! 172: };
! 173:
! 174: /////////////////////////////////////////////////////////////////////////////
! 175: // OLE data (like AUX_DATA)
! 176:
! 177: struct OLE_DATA
! 178: {
! 179: // OLE 1.0 clipboard formats
! 180: UINT cfNative, cfOwnerLink, cfObjectLink;
! 181:
! 182: // OLE 2.0 clipboard formats
! 183: UINT cfEmbeddedObject, cfEmbedSource, cfLinkSource;
! 184: UINT cfObjectDescriptor, cfLinkSourceDescriptor;
! 185: UINT cfFileName, cfFileNameW;
! 186:
! 187: //RichEdit formats
! 188: UINT cfRichTextFormat;
! 189: UINT cfRichTextAndObjects;
! 190:
! 191: OLE_DATA();
! 192: };
! 193:
! 194: extern OLE_DATA _oleData;
! 195:
! 196: /////////////////////////////////////////////////////////////////////////////
! 197: // _AFX_OLE_STATE
! 198:
! 199: #undef AFX_DATA
! 200: #define AFX_DATA
! 201:
! 202: class _AFX_OLE_STATE : public CNoTrackObject
! 203: {
! 204: public:
! 205: _AFX_OLE_STATE();
! 206: virtual ~_AFX_OLE_STATE();
! 207:
! 208: CView* m_pActivateView; // activation view
! 209: COleDataSource* m_pClipboardSource;
! 210:
! 211: DWORD m_dwReserved; // was "parking space" window
! 212: #ifdef _AFXDLL
! 213: HINSTANCE m_hInstOLE; // handle of OLE32.DLL
! 214: HINSTANCE m_hInstOLEAUT; // handle of OLEAUT32.DLL
! 215: HINSTANCE m_hInstOLEDLG; // handle of OLEDLG.DLL
! 216: HINSTANCE m_hInstUrlMon;
! 217: #endif
! 218: long m_nReserved; // was reference count on parking window
! 219: };
! 220:
! 221: EXTERN_PROCESS_LOCAL(_AFX_OLE_STATE, _afxOleState)
! 222:
! 223: /////////////////////////////////////////////////////////////////////////////
! 224: // Global helper functions
! 225:
! 226: // menu merging/unmerging
! 227: HMENU AFXAPI AfxMergeMenus(HMENU hMenuShared, HMENU hMenuSource,
! 228: LONG* lpMenuWidths, int iWidthIndex, BOOL bMergeHelpMenus = FALSE);
! 229: void AFXAPI AfxUnmergeMenus(HMENU hMenuShared, HMENU hMenuSource,
! 230: HMENU hHelpMenuPopup = NULL);
! 231:
! 232: // helpers for IOleCommandTarget
! 233:
! 234: HRESULT AFXAPI _AfxQueryStatusOleCommandHelper(CCmdTarget* pTarget,
! 235: const GUID* pguidCmdGroup, ULONG cCmds, OLECMD rgCmds[],
! 236: OLECMDTEXT* pcmdtext);
! 237: HRESULT AFXAPI _AfxExecOleCommandHelper(CCmdTarget* pTarget,
! 238: const GUID* pguidCmdGroup, DWORD nCmdID, DWORD nCmdExecOpt,
! 239: VARIANTARG* pvarargIn, VARIANTARG* pvarargOut);
! 240:
! 241: // helpers for exceptions
! 242: void AFXAPI _AfxFillOleFileException(CFileException*, SCODE sc);
! 243: void AFXAPI _AfxThrowOleFileException(SCODE sc);
! 244:
! 245: // helper used during object creation
! 246: LPFORMATETC AFXAPI _AfxFillFormatEtc(LPFORMATETC lpFormatEtc,
! 247: CLIPFORMAT cfFormat, LPFORMATETC lpFormatEtcFill);
! 248:
! 249: // helper to copy clipboard data
! 250: BOOL AFXAPI _AfxCopyStgMedium(
! 251: CLIPFORMAT cfFormat, LPSTGMEDIUM lpDest, LPSTGMEDIUM lpSource);
! 252:
! 253: // helper for reliable and small Release calls
! 254: DWORD AFXAPI _AfxRelease(LPUNKNOWN* plpUnknown);
! 255: #ifndef _DEBUG
! 256: // generate smaller code in release build
! 257: #define RELEASE(lpUnk) _AfxRelease((LPUNKNOWN*)&lpUnk)
! 258: #else
! 259: // generate larger but typesafe code in debug build
! 260: #define RELEASE(lpUnk) do \
! 261: { if ((lpUnk) != NULL) { (lpUnk)->Release(); (lpUnk) = NULL; } } while (0)
! 262: #endif
! 263:
! 264: // helpers from OLESTD.C (from original OLE2UI sample)
! 265: HGLOBAL AFXAPI _AfxOleGetObjectDescriptorData(CLSID clsid, DWORD dwDrawAspect,
! 266: SIZEL sizel, POINTL pointl, DWORD dwStatus, LPCOLESTR lpszFullUserTypeName,
! 267: LPCOLESTR lpszSrcOfCopy);
! 268: HGLOBAL AFXAPI _AfxOleGetObjectDescriptorData(LPOLEOBJECT lpOleObj,
! 269: LPCOLESTR lpszSrcOfCopy, DWORD dwDrawAspect, POINTL pointl, LPSIZEL lpSizelHim);
! 270: SCODE AFXAPI _AfxOleDoConvert(LPSTORAGE lpStg, REFCLSID rClsidNew);
! 271: SCODE AFXAPI _AfxOleDoTreatAsClass(
! 272: LPCTSTR lpszUserType, REFCLSID rclsid, REFCLSID rclsidNew);
! 273: DVTARGETDEVICE* AFXAPI _AfxOleCreateTargetDevice(LPPRINTDLG lpPrintDlg);
! 274: DVTARGETDEVICE* AFXAPI _AfxOleCreateTargetDevice(LPDEVNAMES pDN, LPDEVMODE pDM);
! 275: UINT AFXAPI _AfxOleGetUserTypeOfClass(
! 276: REFCLSID rclsid, LPTSTR lpszUserType, UINT cch, HKEY hKey);
! 277: DWORD AFXAPI _AfxOleGetLenFilePrefixOfMoniker(LPMONIKER lpmk);
! 278: DVTARGETDEVICE* AFXAPI _AfxOleCopyTargetDevice(DVTARGETDEVICE* ptdSrc);
! 279: void AFXAPI _AfxOleCopyFormatEtc(LPFORMATETC petcDest, LPFORMATETC petcSrc);
! 280: HDC AFXAPI _AfxOleCreateDC(DVTARGETDEVICE* ptd);
! 281: void AFXAPI _AfxDeleteMetafilePict(HGLOBAL hMetaPict);
! 282: BOOL AFXAPI _AfxOlePropertiesEnabled();
! 283:
! 284: // helper(s) for reliable and small QueryInterface calls
! 285: LPUNKNOWN AFXAPI _AfxQueryInterface(LPUNKNOWN lpUnknown, REFIID riid);
! 286: #define QUERYINTERFACE(lpUnknown, iface) \
! 287: (iface*)_AfxQueryInterface(lpUnknown, IID_##iface)
! 288:
! 289: // helpers for conversion between himetric and pixels
! 290: #define HIMETRIC_PER_INCH 2540
! 291: #define MAP_PIX_TO_LOGHIM(x,ppli) MulDiv(HIMETRIC_PER_INCH, (x), (ppli))
! 292: #define MAP_LOGHIM_TO_PIX(x,ppli) MulDiv((ppli), (x), HIMETRIC_PER_INCH)
! 293:
! 294: // helper for GUID comparison
! 295: inline BOOL _AfxIsEqualGUID(REFGUID guid1, REFGUID guid2)
! 296: {
! 297: return ((DWORD*)&guid1)[0] == ((DWORD*)&guid2)[0] &&
! 298: ((DWORD*)&guid1)[1] == ((DWORD*)&guid2)[1] &&
! 299: ((DWORD*)&guid1)[2] == ((DWORD*)&guid2)[2] &&
! 300: ((DWORD*)&guid1)[3] == ((DWORD*)&guid2)[3];
! 301: }
! 302:
! 303: HRESULT AFXAPI _AfxReadFromStream(LPSTREAM pStream, void* lpBuf, UINT nCount, DWORD& nRead);
! 304:
! 305: /////////////////////////////////////////////////////////////////////////////
! 306: // implementation types and constants
! 307:
! 308: #define OLE_MAXITEMNAME (_countof("Embedding ")+_countof("4294967295")-_countof(""))
! 309:
! 310: typedef LPVOID* LPLP;
! 311:
! 312: #undef AFX_DATA
! 313: #define AFX_DATA
! 314:
! 315: /////////////////////////////////////////////////////////////////////////////
E-mail: