[python-win32] Help calling IProgressDialog Interface

Tim Golden mail at timgolden.me.uk
Wed Feb 27 15:19:46 CET 2008


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


More information about the python-win32 mailing list