[python-win32] RE: drawing a bitmap

Jack Andrews effbiae at ivorykite.com
Fri Apr 22 08:49:24 CEST 2005

thanks mark.

i've got to the bottom of the problem -- there seems to be a problem with
constructing/updating PyBitmaps.

or, more generally, the fuzzy boundary between win32gui and win32ui.  what
do you think about python-wrapping the win32 api, and building the
MFC-like class system in python?  a few win32gui functions are missing,
which means i have to use win32ui.  but i guess there's venster for
that... but it appears pretty inactive.

this code works:


       print bm.GetSize()

--> (944,734)

while this (supposedly evuivalent) code:

       print  bm.GetSize()

--> (0,0)

Mark Hammond said:
>> hi,  i can't seem to create a bitmap in memory using pywin32.
>>  my assert
>> fails, telling me that the bitmap size is (0,0)?
> I'm no expert on GDI programming at all.  However, I have code that
> that looks like:
>     hdcBitmap = win32gui.CreateCompatibleDC(0)
>     hdcScreen = win32gui.GetDC(0)
>     hbm = win32gui.CreateCompatibleBitmap(hdcScreen, size_x, size_y)
hbmOld = win32gui.SelectObject(hdcBitmap, hbm)
>     # draw on hbm
>     win32gui.SelectObject(hdcBitmap, hbmOld)
>     win32gui.DeleteDC(hdcBitmap)
>     win32gui.DeleteDC(hdcScreen)
>     # hbm can now be used.
> That appears subtly different.  The code is from
> win32\Demos\win32gui_menu.py - it draws some bitmaps on menus.
> Mark

More information about the Python-win32 mailing list