[python-win32] HRGN, RGNDATA, RGNDATAHEADER

Tim Roberts timr at probo.com
Tue Jan 15 01:26:24 CET 2008


Henry Baxter wrote:
>
> I'm having some trouble working with window 'regions'. I need to 
> initialize some memory for the region and work with it.
>
> I have copied my best approach so far, but I know I don't know what 
> I'm doing when it comes to the 'Buffer' field in RGNDATA. MSDN 
> describes what HRGN points to (a RGNDATA struct) as:

I don't believe that an HRGN literally points to an RGNDATA struct.  The 
RGNDATA is certainly behind an HRGN, but there's a mapping in there.  
You should use GetRgnData and ExtCreateRegion to convert between them.


> How do I create an arbitrary-size buffer and initialize it? That 
> doesn't really make a lot of sense to me.

In general, the best plan is to leave the RGNDATA management to GDI.  
You should build your region a bit at a time from the simpler structures 
and merge them into your region.  So, use CreateRectRgn to create the 
basic frame, and then add to it with CombineRgn and friends.

Also, you should remember that working with region in Windows can be 
rather inefficient.  A drawing operation that is clipped by a region 
gets sent to the driver multiple times, once for each unique rectangle 
in the region.

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the python-win32 mailing list