How python ActiveX to access DHTML document?

A

angel

Hi

I want to write an ActiveX by using python. And I know how do, but I don't
know how python to access DHTML Document.If using cpp, it can be done by
following source.
/****/
CComPtr<IOleContainer> spContainer;
m_spClientSite->GetContainer(&spContainer);
CComQIPtr<IHTMLDocument2, &IID_IHTMLDocument2> spDoc(spContainer);
if (spDoc)
spDoc->put_bgColor(CComBSTR(_T("pink")));
/****/
Who can tell me how to do the same in python? Thanx

ps. I use win32com package.

Thanx again
angel
 
W

Waldemar Osuch

angel said:
Hi

I want to write an ActiveX by using python. And I know how do, but I don't
know how python to access DHTML Document.If using cpp, it can be done by
following source.
/****/
CComPtr<IOleContainer> spContainer;
m_spClientSite->GetContainer(&spContainer);
CComQIPtr<IHTMLDocument2, &IID_IHTMLDocument2> spDoc(spContainer);
if (spDoc)
spDoc->put_bgColor(CComBSTR(_T("pink")));
/****/
Who can tell me how to do the same in python? Thanx

ps. I use win32com package.

Thanx again
angel

Assuming you want to have HTML Document within IE following should
work from the command line.

I would also recommend running Tools->COM Makepy utility from Pythowin
on Microsoft Internet Controls (for Internet Explorer)
and Microsoft HTML Object Library (for DHTML Document)

waldek
 
A

angel

Thanx, but you mistook my meanings.
(1)I wrote ActiveX.
(2)The ActiveX will be embed in a html page.
(3)The ActiveX want to know the container html document's IDispatch pointer.

Your solution can only create a new document, and then control it.

Thanx again
angel
 
M

Mark Hammond

angel said:
Hi

I want to write an ActiveX by using python. And I know how do, but I don't
know how python to access DHTML Document.If using cpp, it can be done by
following source.
/****/
CComPtr<IOleContainer> spContainer;
m_spClientSite->GetContainer(&spContainer);
CComQIPtr<IHTMLDocument2, &IID_IHTMLDocument2> spDoc(spContainer);
if (spDoc)
spDoc->put_bgColor(CComBSTR(_T("pink")));
/****/
Who can tell me how to do the same in python? Thanx

IOleContainer isn't supported by win32com. Let me know if you are
interested in helping add it (it is very hard to add new interface
support correctly without a usecase)

In the meantime, try and find an IDispatch based way of doing it.

Mark.
 
A

angel

Hi everyone

Thank you for your reply.
The use case is:
1) I wrote a com server(progid is PythonCom.Test)in Python. It works well.
2) The com server expose some method func1 func2 ...
3) In a html I wrote a jscript
var com = new ActiveXObject("PythonCom.Test");
com.func1(); // it's ok
com.func2(); //it's ok too.
4)Now I want my com server can access the html document directly.
I hope my com server can call
document.all.id1.innerText ="Hello world!"

I know the key is to get the html document's IDispatch. but how to do? I
have tried let a jscript call:
com.func3(document);
but the page report error.

Thanx again.
angel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top