[python-win32] Help calling IProgressDialog Interface
Thomas Heller
theller at ctypes.org
Tue Feb 26 16:35:09 CET 2008
Larry Bates schrieb:
> Thomas Heller wrote:
>> Larry Bates schrieb:
>>> I've spent all morning searching and I just can't seem to find the TypeLibrary
>>> name for this COM interface.
>> Sometimes someone who wants to use the object from VB writes an idl file
>> and compiles a typelib (but you could also try it yourself, maybe).
>> With a little googling I found a zip-file containing such a library:
>>
>> http://www.msjogren.net/dotnet/eng/samples/vb6_progdlg.asp
> Ok, I downloaded that project, and stripped out the TLB. I then got comtypes
> and was able to use comtypes.client.GetModule to generate the typelib wrapper
> module for it:
>
> >>> GetModule("progdlg.tlb")
> <module 'comtypes.gen.VBProgressDialog' from
> 'C:\Python25\lib\site-packages\comtypes\gen\_2F2719A2_83CC_11D3_A08C_0040F6A4BFEC_0_1_1.pyc'>
> >>> import comtypes.gen.VBProgressDialog
>
> Now I can't seem to figure out what to do. There are three classes generated:
>
> class IOleWindow(comtypes.IUnknown)
> class IProgressDialog(comtypes.IUnknown)
> class ProgressDialog(comtypes.CoClass)
>
> Instantiating IProgressDialog() seems to give me an instance that has the
> methods that I'm looking for (at least they show up in Idle as callable
> methods), but when I try to call one I get the following message:
Larry, you do not instantiate the generated classes directly. You must use
the comtypes.client.CreateObject function to do that for you, passing the CoClass
as parameter. I think that this code should work:
import comtypes.gen.VBProgressDialog
from comtypes.client import CreateObject
dia = CreateObject(comtypes.gen.VBProgressDialog.ProgressDialog)
dia.StartProgressDialog(....)
Thomas
More information about the python-win32
mailing list