Fwd: [python-win32] win32gui, win32ui -- how to release references?

Marcus Goldfish magoldfish at gmail.com
Mon Mar 21 22:23:54 CET 2005


> > screen capturing using win32gui + win32ui, [though I am still looking
> > for a solution that works without win32ui].
> Why?  win32ui is just a wrapper around user32.dll.  That's the way you
> get UI stuff done on Windows.
Why not!?  (couldn't resist)

Actually, it is my understanding that one might want to avoid MFC if
plans include deployment to WinCE devices.  Also, I am not an MFC
programmer so using MFC classes & paradigms just adds another level of
complexity to the task [e.g., the resource release question: does MFC
do it automatically?  Does the win32ui wrap of MFC also do it
automatically?]

I am not opposed to using win32ui, but for this task I prefer a
simpler alternative.  For instance, I am also implementing screen
capture using the ctypes extension, and I would like to compare the
two solutions.  My ctypes implementation doesn't use MFC (aside: is it
even possible to use MFC with ctypes?).

Also, is win32ui really just a wrapper of user32dll?  I thought it was
a wrap of MFC-- these two things aren't the same, are they?


> >In the C/C++ code snippets I've seen, the cleanup step usually
> >involves ReleaseDC(hwnd, hDC), DeleteDC(myDC), and
> >DeleteObject(myBitmap).
>> Are these steps automatically handled in
> >Python by win32gui and win32ui?  If not, can someone post a snippet of
> Yes, it is automatic.  When the objects are destroyed, the resources
> will be released.
Mark, perhaps you could chime in on this.  Your previous response
seemed to indicate that the win32ui objects (e.g., the PyBitmap) would
be automatically handled, but that I would need to explicitly release
the win32gui objects.  This seems to me to contradict Tim's assertion.
 Not to start a contest, but is there a definitive answer to which of
these resources

   hDC, myDC, myBitmap

I need to cleanup myself, and which I can defer to python?

Marcus


More information about the Python-win32 mailing list