473,569 Members | 2,590 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

QueryInterface on IDispatch in Python ...

I am working with the MSHTML editor control. I used
win32com.client .gencache.Ensur eModule on the MSHTML type library to
generate the necessary IDispatch support for all the various
interfaces used by MSHTML.

I have just implemented some of the necessary custom COM
interfaces/gateways to allow me to take control of MSHTML's
right-click menu.

One of the callbacks that MSHTML makes (and I've implemented) is
'ShowContextMen u' (on the IDocHostUIHandl er interface). One of the
arguments passed to ShowContextMenu is a generic IDispatch reference
to the current HTML Element - ultimately this is an IHTMLElement
interface reference.

Python understands that this reference passed to 'ShowContextMen u' is
an IDispatch interface but when I do a QueryInterface on this object
to get the IHTMLElement interface (like so:)

element = dispElement.Que ryInterface(IID ('{3050F1FF-98B5-11CF-BB82-00AA00BDCE0B}') )

I get the following error:

exceptions.Type Error: {There is no interface object registered that
supports this IID}

What am I doing wrong? IHTMLElement *is* defined in the module .py
file that was generated by EnsureModule from the type library,
IHTMLElement is derived from IDispatch. Shouldn't I be able to make
late-bound calls on the generic IDispatch reference?

Any help would be greatly appreciated.
Jul 18 '05 #1
1 4515
You should be able to use Dispatch to get the desired interface,
something like this:
win32com.client .Dispatch(eleme nt, None,
IID('{3050F1FF-98B5-11CF-BB82-00AA00BDCE0B}')
hth
Roger

"Peter Sparago" <ps******@yahoo .com> wrote in message
news:58******** *************** ***@posting.goo gle.com...
I am working with the MSHTML editor control. I used
win32com.client .gencache.Ensur eModule on the MSHTML type library to
generate the necessary IDispatch support for all the various
interfaces used by MSHTML.

I have just implemented some of the necessary custom COM
interfaces/gateways to allow me to take control of MSHTML's
right-click menu.

One of the callbacks that MSHTML makes (and I've implemented) is
'ShowContextMen u' (on the IDocHostUIHandl er interface). One of the
arguments passed to ShowContextMenu is a generic IDispatch reference
to the current HTML Element - ultimately this is an IHTMLElement
interface reference.

Python understands that this reference passed to 'ShowContextMen u' is
an IDispatch interface but when I do a QueryInterface on this object
to get the IHTMLElement interface (like so:)

element =
dispElement.Que ryInterface(IID ('{3050F1FF-98B5-11CF-BB82-00AA00BDCE0B}') )

I get the following error:

exceptions.Type Error: {There is no interface object registered that
supports this IID}

What am I doing wrong? IHTMLElement *is* defined in the module .py
file that was generated by EnsureModule from the type library,
IHTMLElement is derived from IDispatch. Shouldn't I be able to make
late-bound calls on the generic IDispatch reference?

Any help would be greatly appreciated.

Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1149
by: Ian Adams | last post by:
How do I do this in Python? hres = pObj->QueryInterface(IID_MyIntf1, (void **) &piMyIntf1); piMyIntf1->QueryInterface(IID_MyIntf2, (void **) &piMyIntf2); piMyIntf2->SomeMthd(args); Also, how do I call/manage smart pointer interfaces?
3
2771
by: Roger That | last post by:
Hi, I am trying to use the function "CreateStreamOnHGlobal" from python code (I need to pass an IStream object to MSXML, like I do in C++ code). I was able to retrieve a pointer on the IStream object in this way: from ctypes import * stream = c_int()
1
15616
by: Dmitry Medvedev | last post by:
Hello, I need to write C# class, that would implement IDispatch interface to be used in ActiveScript. I can't use IReflect interface here due to design issues, I need to handle GetIDsOfNames and Invoke manually. I've tried the following code:
4
5400
by: Phil Coveney | last post by:
Hello, I am implementing a class in C# that wraps an automation server and am stuck on something basic. Using the following code fragment: using System; using System.Runtime.InteropServices; namespace ANamespace {
0
3449
by: Jim Hubbard | last post by:
How would I implement the IDispatch interface to handle the following in VB.Net <BEGIN> Controlling Download and Execution The WebBrowser Control gives you control over what it downloads, displays, and executes. To gain this control, you need to implement your host's IDispatch so it handles DISPID_AMBIENT_DLCONTROL. When the WebBrowser...
1
3728
by: fraca7 | last post by:
Hello. I got a little problem while using pythoncom to automate IE; for some reason, changing the 'selectedIndex' on an instance of IHTMLSelectElement doesn't fire the 'onchange' event (I guess this is a bug in mshtml). So, I tried to get the 'onchange' event handler and call it myself. According to the docs, this is a simple IDispatch...
3
2411
by: ZhaoYingpu | last post by:
Hello,all I am using win32com to use com. and invoke a method as follows: void AddShapeInfo(LPCTSTR name, LONG type, IDispatch* pDisp); but i pass 0 or None to third parameter and get error info: Traceback (most recent call last): File "<pyshell#9>", line 1, in <module> x.AddShapeInfo("who", 10, 0) File "<COMObject xxx.Document>", line...
0
959
by: Brad Johnson | last post by:
I have a C++ application that creates a collection of COM objects. I would like to give the Python interpreter access to these interfaces that were created in C++ land. Stated another way, how can I have Python consume a IDispatch pointer from C++ and wrap it with one of those nice Python classes automatically? Thanks in advance.
3
2726
by: Huayang Xia | last post by:
I am trying to use ctypes to call dll functions. One of the functions requires argument "struct IDispatch* ". I do have a PyIDispatch object in python. How can I convert this "PyIDispatch object" to "struct IDispatch* "? Thanks in advance.
0
7701
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7924
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8130
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7979
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6284
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
2115
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1223
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
940
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.