By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,772 Members | 937 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,772 IT Pros & Developers. It's quick & easy.

How python ActiveX to access DHTML document?

P: n/a
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
Jul 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
"angel" <da*******@yahoo.com> wrote in message news:<c7***********@news.f.de.plusline.net>...
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.
from win32com.client import Dispatch
ie = Dispatch("InternetExplorer.Application")
ie.Visible = True
ie.Navigate('about:blank')
doc = ie.Document
doc.bgColor = "pink"


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
Jul 18 '05 #2

P: n/a
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
"Waldemar Osuch" <os****@ecn.ab.ca>
??????:c5**************************@posting.google .com...
"angel" <da*******@yahoo.com> wrote in message

news:<c7***********@news.f.de.plusline.net>...
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.
from win32com.client import Dispatch
ie = Dispatch("InternetExplorer.Application")
ie.Visible = True
ie.Navigate('about:blank')
doc = ie.Document
doc.bgColor = "pink"


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

Jul 18 '05 #3

P: n/a
angel wrote:
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.
Jul 18 '05 #4

P: n/a
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

Jul 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.