我使用以下JS代码创建一个新的ActiveX对象
var playerDiv = document.createElement("div");
playerDiv.style.border = "1px solid red";
var size = 200 + 20 * index;
playerDiv.style.width = 200 + 20 * index + "px";
playerDiv.style.height = 200 + 20 * index + "px";
playerDiv.setAttribute("id", 'divPlayer' + index);
var str = '<object id="player' + index + '" classid="CLSID:69A1BC06-C88F-4849-81E7-DB0AB0628819" width="' + size + '" height="' + size + '"></object>';
playerDiv.innerHTML = str;
divViewPort.appendChild(playerDiv);
而playerDiv是一个简单的DIV标签。我的问题发生在innerHTML绑定期间,在绑定过程中,构造了一个新的activeX对象,但是我没有接收来自JS引擎的调用来构造m_hWnd变量。查看传统代码, 调用堆栈:
> BCPlayer.dll!CSinglePlayer::CreateControlWindow(HWND__ * hWndParent, tagRECT & rcPos) Line 3207 C++
BCPlayer.dll!ATL::CComControlBase::InPlaceActivate(long iVerb, const tagRECT * __formal) Line 1037 C++
BCPlayer.dll!ATL::IOleObjectImpl<CSinglePlayer>::DoVerbInPlaceActivate(const tagRECT * prcPosRect, HWND__ * __formal) Line 2263 C++
BCPlayer.dll!ATL::IOleObjectImpl<CSinglePlayer>::DoVerb(long iVerb, tagMSG * __formal, IOleClientSite * pActiveSite, long __formal, HWND__ * hwndParent, const tagRECT * lprcPosRect) Line 2363 C++
mshtml.dll!COleSite::InPlaceActivate(struct IOleObject *,struct HWND__ *,struct tagMSG *) Unknown
mshtml.dll!COleSite::TransitionTo(enum OLE_SERVER_STATE,struct tagMSG *) Unknown
mshtml.dll!COleSite::TransitionToBaselineState(enum OLE_SERVER_STATE) Unknown
mshtml.dll!COleSite::EnterTree(void) Unknown
mshtml.dll!COleSite::Notify(class CNotification *) Unknown
mshtml.dll!CObjectElement::Notify(class CNotification *) Unknown
mshtml.dll!CSpliceTreeEngine::InsertSplice(void) Unknown
mshtml.dll!__chkstk() Unknown
mshtml.dll!CDoc::CutCopyMove(class CMarkupPointer *,class CMarkupPointer *,class CMarkupPointer *,int,unsigned long) Unknown
mshtml.dll!InjectHtmlStream(class CMarkupPointer *,class CMarkupPointer *,struct IStream *,unsigned long,class CElement *,enum INJECTION_FLAGS,class CElement *,enum ELEMENT_TAG,bool,unsigned int,enum CPSRCE) Unknown
mshtml.dll!HandleHTMLInjection(class CMarkupPointer *,class CMarkupPointer *,unsigned short const *,long,class CElement *,enum INJECTION_FLAGS,class CElement *,enum ELEMENT_TAG) Unknown
mshtml.dll!CElement::InjectInternal(enum CElement::Where,unsigned short const *,long,enum INJECTION_FLAGS) Unknown
mshtml.dll!CElement::InjectTextOrHTML(enum CElement::Where,bool,unsigned short const * const,int) Unknown
mshtml.dll!CElement::put_innerHTML(unsigned short *) Unknown
以下功能:
CSinglePlayer::CreateControlWindow(HWND hWndParent, RECT& rcPos)
是public CComControl<CSinglePlayer>
的覆盖。
执行CComControl<CSinglePlayer>::CreateControlWindow(hWndParent, rcPos);
一旦我们理解了遗留代码的工作方式,我的对象上使用的innerHTML,甚至从未执行任何IOleObjectImpl函数,我设法模拟工作环境的唯一方法是通过引发OnClick()事件来强制JS调用所需的函数并生成m_hWnd。 我继承了以下接口/类:
class /*ATL_NO_VTABLE*/
__declspec(uuid("{69A1BC06-C88F-4849-81E7-DB0AB0628819}"))
VPlayer :
public CComObjectRootEx<CComMultiThreadModel>
//, public ATL::CWindowImpl<VPlayer, ATL::CWindow, ATL::CFrameWinTraits>
, public IObjectSafetyImpl<VPlayer, INTERFACESAFE_FOR_UNTRUSTED_CALLER |INTERFACESAFE_FOR_UNTRUSTED_DATA>
, public CComCoClass<VPlayer, &__uuidof(VPlayer)>
, public IDispatchImpl<IVPlayerControl>
, public IDispatchImpl<IVPlayerSpeed>
, public IDispatchImpl<IMetadata>
, public IStreamingSourceCallback
, public IPlayerEx
, public CComControl<VPlayer>
, public IOleControlImpl<VPlayer>
, public IOleObjectImpl<VPlayer>
, public IOleInPlaceActiveObjectImpl<VPlayer>
, public IViewObjectExImpl<VPlayer>
, public IOleInPlaceObjectWindowlessImpl<VPlayer>
, public IQuickActivateImpl<VPlayer>
m_bWindowOnly = TRUE;
感谢
答案 0 :(得分:0)
使用朋友的建议,我们了解到.rgs文件不知怎的变了。 以下代码段丢失了:
'TypeLib' = s '{02BED0E7-FD7C-49a5-A046-C1008BA2660B}'
'MiscStatus' = s '0'
{
'1' = s '%OLEMISC%'
}