Larry Bates wrote:
> Tim Golden wrote:
>> Larry Bates wrote:
>>> 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.
>>> ' 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
>> Which bit aren't you getting, Larry? (Not sure how far your
>> existing expertise extends). The LoadLibrary stuff is what
>> ctypes.windll encapsulates. ie
>>
>> <code>
>> import ctypes
>> shell32 = ctypes.windll.shell32
>> m_hLibShell32 = shell32._handle
>> </code>
>>
>> gets you the same as the Form_Load Sub. Alternatively, you
>> could import the lower-level _ctypes and use its LoadLibrary
>> binding directly:
>>
>> <code>
>> import _ctypes
>> m_hLibShell32 = _ctypes.LoadLibrary ("shell32.dll")
>>
>> #
>> #
>>
>> _ctypes.FreeLibrary (m_hLibShell32)
>> </code>
>>
>> But maybe that's not the bit you're having trouble with?
>>
>> TJG
> 
> Tim,
> 
> That did the trick.  It was the:
> 
> m_hLibShell32 = shell32._handle
> 
> that I needed.
> 
> Thanks loads.
> 
> -Larry


One last problem.  When I working class inside my COM object and everything 
works until I (or Python) destroys the reference to this object.  I then get 
this exception:

Exception exceptions.ValueError: 'COM method call without VTable' in <bound meth
od POINTER(IProgressDialog).__del__ of <POINTER(IProgressDialog) ptr=0x2670c8 at
  1ef5e90>> ignored

I tried putting del inside try block with blank exception (normally a bad idea 
but in this case I thought it would be OK) as follows:

try:
     del CB

except:
     pass

and

try:
     del CB

except pythoncom.com_error:
     pass


but neither of these worke (e.g. exception still echos to console).

I guess I'm missing a step in "properly" destroying this object, but I can't 
seem to determine what it is.  Any suggestions would be greatly appreciated.

Regards,
Larry

_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to