[python-win32] Help calling IProgressDialog Interface
Larry Bates
larry.bates at websafe.com
Wed Feb 27 14:56:13 CET 2008
Thomas Heller wrote:
> 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
Thomas,
I almost have it completely working with one remaining problem. The dialog
allows the user to specify an AVI that runs showing activity while things are
going in the background. There are AVIs stored in shell32.dll for move/copy
(resource number 160 and 161 respectively). Below is the VB code to set these,
but I'm not getting anywhere trying to convert. I was hoping you could take a
quick look.
Thanks for your help. I'll be happy to share the class when I'm done if you are
interested or can you suggest a good place to post? Might be a good comtypes
example????
Regards,
Larry
' File operation animations resource IDs in shell32.dll
Private Const RES_AVI_FILEMOVE = 160
Private Const RES_AVI_FILECOPY = 161
With oProgDlg
.SetTitle IIf(fMove, "Moving file...", "Copying file...")
.SetAnimation m_hLibShell32, IIf(fMove, RES_AVI_FILEMOVE, RES_AVI_FILECOPY)
.SetLine 1, txtSource.Text, 1&, ByVal 0&
.SetLine 2, txtDest.Text, 1&, ByVal 0&
.SetCancelMsg "Please wait...", ByVal 0&
.StartProgressDialog Me.hwnd, Nothing, PROGDLG_MODAL Or _
PROGDLG_AUTOTIME Or _
PROGDLG_NOMINIMIZE, ByVal 0&
End With
Private Sub Form_Load()
' Load Shell32 to access the AVI animation resources
m_hLibShell32 = LoadLibrary("shell32.dll")
End Sub
Private Sub Form_Unload(Cancel As Integer)
Call FreeLibrary(m_hLibShell32)
End Sub
More information about the python-win32
mailing list