MFC ???? ???? ????? C++ 5.0 Microsoft ?? ??? ??? ???? ??? ???????? ?????? ?????? ???? ??? ?? containment ?????? ?? majority undocumented ?? ???? ???? ??? ???? ???? ??? ??? ??? ????? ????????? ?? ??? ??? ?? ???? ?? derive ?? several MFC ???????? ???????? ??????? ??????? ?? ??????? ??????? ?? ??????? ???? ?? ??? ??????? ???
???????:: ??????????? ?? ????? ??? ???? ??????? ?? MFC ?? ???? ?? ?????? ?? ?? ?? ??? ??? ??? ???? ?????? ?? ???? ??????? ??????? ??? ?? ??????? ?? ??? ???? ????????? ???? ?? ???, ????? ???? ???? ????? ???? ????? ??? ??? ?? ?? ???? ?? ????? Microsoft ?????? ?????? ???? ?????? undocumented ???? ?? ????? ???? ?? ?? ???? ?? ??? ??? ???? ?????? ?? ??? ???? ?????? ???? ?? ????
MFC ???????? ?????? ?????? involves ??? ????? ????: COccManager, COleControlContainer, ?? COleControlSite. COccManager ?? MFC ????????? ??? ??? ???????? ?????? ?? ??? ??????-???????? ?? ?? COleControlSite ?? COleControlContainer ?????????? ?? ??? ???? ?? ???? handing ?? ??? ?????????? ??? COccManager ?? ?? IsDialogMessage ???? ?? ActiveX ???????? ?????? ?????? ?????? ??????????? ?? ??????? ???? ??? ????? ?? ???? ???? ???
COleControlContainer ?????? ?? ?? ?? ???? ActiveX ?????????? ?? ??? ???? ???? ??? ?? ?????? ??? ???? ActiveX ???????? ?? ???? ???? ?????????? ?? ????? ???? ???????? ????????? ?? ????? ????? ?? ???? ??? ??????????, ?? ?? ?? ????? ????? ???? ???? ???????? ???????? ?? ??? ??? COleControlContainer ???? ?? ????????: IOleInPlaceFrame ?? IOleContainer.
???????? ???????? hosted ???????? ???????? ???????? ??? ??, ?? ??? ???? ??? ???? MFC ???????? ???? ???????? ??? ?? ???????? ???? ???????? COleControlSite ?????? ???? ???? ??? ??? ???? one-on-one ???? ???? ???????? ?? ??? ??? ?? ??????? ActiveX ???????? ?? ???, COleControlSite ???? ?? ????????: IOleClientSite, IOleInPlaceSite, IOleControlSite, IPropertyNotifySink, IBoundObjectSite, INotifyDBEvents. ???? COleControlSite ?? ???? ?? IDispatch ????????, ambient ????? ?? ??? ?? ?? ????? ?? ??? ??? ???? ?????? ???????? ?? ??? ???
?? ???? ?? ?? ??? ???????? ?? ????? ?? COleControlContainer ?? COleControlSite ??? ??????? ???? ?? ??????????? ?? ?????? ?? ??? ?? ??????? ???? ?? ??? ?????? ????? ?? ?????? ????? ???
COleControlContainer ??????? ???? ?? ??? ???
- ?? ???? COleControlContainer ?? ?????? Constructor ?? ????, COleControlContainer constructor ?? ??? ???? ?? ???????? ?? ???? ??? ???????? COleControlContainer constructor ??:
CMyOleControlContainer::CMyOleControlContainer(CWnd* pWnd) :
COleControlContainer(pWnd)
{
}
- ?? ???? COccManager ?? ?????? ??? ???? constructor ?? ???? ??????? destructor ??? ???????
- ????? ?? ???? ?? COleControlContainer ??? ???? ?? ?? ?? ??????? ?? ???? ???? ?? ??? COccManager::CreateContainer ?????? ??????? ????? ?? ?? ???? ???? COccManager ???? ?? ???????? ???? ?? ??? ????? ???? ???? ?? ???? ???:
virtual COleControlContainer* CreateContainer(CWnd* pWnd)
{
// Advanced control container applications may want to override.
return new CMyOleControlContainer(pWnd);
}
- ???? ??? ???? ?? ??? (?????? ??? CYourApp::InitInstance) AfxEnableControlContainer COccManager ??? ???? ?? ??????? ??? ??? ???? ?? ??? ??????? ????:
CMyOccManager theManager;
// ...
BOOL CMfcaxscrvbApp::InitInstance()
{
// Initialize OLE libraries
if (!AfxOleInit())
// ...
AfxEnableControlContainer(&theManager);
???:: ???? CHtmlView ??? ???? ?? ???, ???? ????? ?????? ??? AfxEnableControlContainer() ???? ???? ????? ????????? ????? COccManager ???? ?? ???????? ???? ?? ???? ?? ?????? ?? ????, ?? ??? ???? CHtmlView::Create ???????, ???? overridden ????? ?????? ?? ??? ???? ?? ??? AfxEnableC ntrolContainer() ??? ??? ??? ??? ?? ????????? ????? ?? ???????? ??? ??? ??????????? ???? ??? ??????? ???? ???? ????? ?????? ?? ??? ???? ?? ??? ???? ??? ?????
- ???? CMyOccManager ??? Occimpl.h ????? ??? ???? ?? ????? ???? ?? ???? CMyOccManager ????? ??? ???? ??????????? ?????? ?? ???? ?????? ??? # Occimpl.h VC/MFC/SRC ?????????? ?? ??????? ??? ?? ????? ???? ?? ???????? ?? ???? ???
- Occimpl.h ????? ??? ???? ?? CMyOleControlContainer ???? ?? ???? ???? CMyOleControlContainer ??????????? ????? ??? ????? ????? ??? ????? ????? AFX_DATA insure ?? ?? Occimpl.h ??? ????????? ???? ?? ???? ???? ???? ?? ??? ????????? ???? ??:
#undef AFX_DATA
#define AFX_DATA AFX_DATA_IMPORT
#include "c:\program files\devstudio\vc\mfc\src\occimpl.h"
#undef AFX_DATA
#define AFX_DATA AFX_DATA_EXPORT
- ??? ???????? CMyOleControlContainer ???? ??? ???????? ???? ?? ??? ???? ????????? ?? ???? ???????? ???? ???? ?? ???? ??? ???? ????? ?? ???, ????? ???? ?????? ?? ????? ?? ???? ?? Microsoft ???????? ??? ?????::
141277
(http://support.microsoft.com/kb/141277/
)
??? ???????? ??? ?? MFC ????????? ??????? ???? ?? ??? ???? ????
???? IOleInPlaceFrame ???????? ?? ??????? ???? ???? ?? ??????? ?????? ??:
// Inside header definition in .h.
class CMyOleControlContainer : public COleControlContainer
{
// ...
// Interface maps.
BEGIN_INTERFACE_PART(MyOleIPFrame, IOleInPlaceFrame)
INIT_INTERFACE_PART(CMyOleControlContainer, MyOleIPFrame)
STDMETHOD(GetWindow)(HWND*);
STDMETHOD(ContextSensitiveHelp)(BOOL);
STDMETHOD(GetBorder)(LPRECT);
STDMETHOD(RequestBorderSpace)(LPCBORDERWIDTHS);
STDMETHOD(SetBorderSpace)(LPCBORDERWIDTHS);
STDMETHOD(SetActiveObject)(LPOLEINPLACEACTIVEOBJECT,
LPCOLESTR);
STDMETHOD(InsertMenus)(HMENU, LPOLEMENUGROUPWIDTHS);
STDMETHOD(SetMenu)(HMENU, HOLEMENU, HWND);
STDMETHOD(RemoveMenus)(HMENU);
STDMETHOD(SetStatusText)(LPCOLESTR);
STDMETHOD(EnableModeless)(BOOL);
STDMETHOD(TranslateAccelerator)(LPMSG, WORD);
END_INTERFACE_PART(MyOleIPFrame)
DECLARE_INTERFACE_MAP()
};
// Inside implementation file .cpp:
BEGIN_INTERFACE_MAP(CMyOleControlContainer, COleControlContainer)
INTERFACE_PART(CMyOleControlContainer, IID_IOleInPlaceFrame,
MyOleIPFrame)
END_INTERFACE_MAP()
STDMETHODIMP CMyOleControlContainer::XMyOleIPFrame::QueryInterface(
REFIID iid, LPVOID* ppvObj)
{
METHOD_PROLOGUE_EX_(CMyOleControlContainer, MyOleIPFrame)
return (HRESULT)pThis->InternalQueryInterface(&iid, ppvObj);
}
STDMETHODIMP_(ULONG) CMyOleControlContainer::XMyOleIPFrame::AddRef()
{
METHOD_PROLOGUE_EX_(CMyOleControlContainer, MyOleIPFrame)
return (ULONG)pThis->InternalAddRef();
}
// ...
// Cut and paste all of this code from the MFC source in Occimpl.h
// and change all references to COleControlContainer to reference
// your class. Then, modify methods as desired. For example, here is
// a customized enablemodeless call:
STDMETHODIMP
CMyOleControlContainer::XMyOleIPFrame::EnableModeless(BOOL f)
{
METHOD_PROLOGUE_EX(CMyOleControlContainer, MyOleIPFrame)
CWinApp* pApp = AfxGetApp();
if (!pApp)
return E_FAIL;
pApp->EnableModeless(f);
return S_OK;
}
COleControlSite ??????? ???? ?? ??? ???
COleControlSite ?? ??????? ???? ?? ??? COleControlContainer substituting COleControlSite COleControlContainer ?? ??? ??????? ???? ?? ??? ?? ??? ??? ?? ?? ????? ?? ???? ????? ??? ????????? ??? snippets ?? ???? ????:
CMyOleControlSite::CMyOleControlSite(COleControlContainer* pCtrlCont) :
COleControlSite(pCtrlCont)
{
}
COccManager::CreateSite COleControlSite ?????????? ????? ?? ??? ????? ???? ???? ???
???? ControlSite ???? ?? ?????, ???? COccManager ???? ?? ??? ????? ???? ?????? ??????? ????:
virtual COleControlSite* CreateSite(COleControlContainer* pCtrlCont)
{
// advanced control container override
return new CMyOleControlSite(pCtrlCont);
}
???? ??????? ?????? IOleControlSite ???????? ?? ??????? ???? ???? ????????:
// Inside header definition in .h:
class CMyOleControlSite : public COleControlSite
{
// ...
// Interface maps.
BEGIN_INTERFACE_PART(MyOleControlSite, IOleControlSite)
INIT_INTERFACE_PART(CMyOleControlSite, MyOleControlSite)
STDMETHOD(OnControlInfoChanged)();
STDMETHOD(LockInPlaceActive)(BOOL fLock);
STDMETHOD(GetExtendedControl)(LPDISPATCH* ppDisp);
STDMETHOD(TransformCoords)(POINTL* lpptlHimetric,
POINTF* lpptfContainer, DWORD flags);
STDMETHOD(TranslateAccelerator)(LPMSG lpMsg, DWORD grfModifiers);
STDMETHOD(OnFocus)(BOOL fGotFocus);
STDMETHOD(ShowPropertyFrame)();
END_INTERFACE_PART(MyOleControlSite)
DECLARE_INTERFACE_MAP()
};
// Inside implementation file .cpp:
BEGIN_INTERFACE_MAP(CMyOleControlSite, CMyOleControlSite)
INTERFACE_PART(CMyOleControlSite, IID_IOleControlSite,
MyOleControlSite)
END_INTERFACE_MAP()
STDMETHODIMP_(ULONG) CMyOleControlSite::XMyOleControlSite::AddRef()
{
METHOD_PROLOGUE_EX_(CMyOleControlSite, OleControlSite)
return (ULONG)pThis->InternalAddRef();
}
STDMETHODIMP_(ULONG) CMyOleControlSite::XMyOleControlSite::Release()
{
METHOD_PROLOGUE_EX_(CMyOleControlSite, OleControlSite)
return (ULONG)pThis->InternalRelease();
}
// ...
// Cut and paste all of this code from the MFC source in Occimpl.h
// and change all references to COleControlSite to reference your
// class. Then, modify methods as desired.
??? ???????? ??? ?? MFC ????????? ??????? ???? ?? ??? ???? ???? ?? ???? ??? ???? ??????? ?? ??? Microsoft ???????? ??? ???? ????? ?? ??? ????? ???? ?????? ?? ????? ????:
141277
(http://support.microsoft.com/kb/141277/
)
??? ???????? ??? ?? MFC ????????? ??????? ???? ?? ??? ???? ????
???? ID: 196835 - ????? ???????: 03 ?????? 2010 - ??????: 4.0
???? ???? ???? ??:
- Microsoft Foundation Class Library 4.2, ?? ???? ??? ?????? ???? ???:
- Microsoft Visual C++ 5.0 Enterprise Edition
- Microsoft Visual C++ 5.0 Professional Edition
| kbcode kbcontainer kbhowto kbmt KB196835 KbMthi |
???? ?????? ??????????????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??:
196835
(http://support.microsoft.com/kb/196835/en-us/
)