How to insert ActiveX control in web page dynamically?
I tried to insert ActiveX control in web page dynamically.
I programmed as below..
... and ActiveX control was inserted successfully.
But the ActiveX Control couldn't receive the property "src" 's value
"success" in <param>.
There aren't any problems int ActiveX control that is called. It works well
in common situation.
How can I solve this problem...?
------------------------------------------------------------------------------------------
int CDynamicActivexCtrl::OnCreate(LPCREATESTRUCT lpCreateStruct){
....
// Create Obejct Element
pObjectElement = CreateElement(L"<object>");
SetAttribute(pObjectElement, L"classid",
L"clsid:AF0DDB60-76F8-4ADC-BF58-563EB7DF2B9D");
SetAttribute(pObjectElement, L"width", L"600");
SetAttribute(pObjectElement, L"height", L"400");
....
// Create Param Element
pParamElement = CreateElement(L"<param>");
SetAttribute(pParamElement, L"name", L"src");
SetAttribute(pParamElement, L"value", L"success!!");
// append Object, Param Element
AppendChild(pObjectElement, pParamElement);
AppendChild(pBody, pObjectElement);
}
IHTMLElement* CDynamicActivexCtrl::CreateElement(CString eleName){
....
hr = m_pDoc2->createElement(bstrAttr=SysAllocString(eleName), &pNewElement);
....
return pNewElement;
}
HRESULT CDynamicActivexCtrl::SetAttribute(IHTMLElement* element, CString
eleName, CString eleValue){
....
hr = element->setAttribute(name, value, 0);
....
}
HRESULT CDynamicActivexCtrl::AppendChild(IHTMLElement* parent, IHTMLElement*
child){
....
if (S_OK != parent->QueryInterface (IID_IHTMLDOMNode, (LPVOID*)&pIDOMNode))
goto err_clear;
if (S_OK != child->QueryInterface (IID_IHTMLDOMNode,
(LPVOID*)&pIDOMNodeChild)) goto err_clear;
hr = pIDOMNode->appendChild (pIDOMNodeChild, NULL);
....
}
HRESULT CDynamicActivexCtrl::AppendChild(IHTMLBodyElement* parent,
IHTMLElement* child){
....
if (S_OK != parent->QueryInterface (IID_IHTMLDOMNode, (LPVOID*)&pIDOMNode))
goto err_clear;
if (S_OK != child->QueryInterface (IID_IHTMLDOMNode,
(LPVOID*)&pIDOMNodeChild)) goto err_clear;
hr = pIDOMNode->appendChild (pIDOMNodeChild, NULL);
....
}
date: Fri, 27 Jun 2008 10:49:01 -0700
author: gimdeon