[python-win32] HRGN, RGNDATA, RGNDATAHEADER
Henry Baxter
henry.baxter at gmail.com
Tue Jan 15 02:10:25 CET 2008
Thanks Tim, all of that makes a lot of sense.
I created a region from a series of points, used the region, and everything
works perfectly. I'm interested to know if you know of a better way to do
what I'm doing though, since you are obviously quite knowledgeable :)
I have an application with a graphical background and rounded corners. The
rounding requires that a certain very small portion of the rectangular
window area be fully transparent and/or not there at all. My first attempt
was with SetLayeredWindowAttributes using LWA_COLORKEY. This was very simple
to implement, and worked perfectly - but it was slow. On non hardware
accelerated heads, the application was very sluggish being dragged around.
My next attempt was with UpdateLayeredWindow, but I had a pretty rough time
finding information on that, so I struck upon window regions - after all, I
was not looking for alpha blending, just 'there' and 'not there' on a few
pixels. Now I hear from you that window regions may not be so efficient :)
I have calculated that the window region requires 7 different rectangles,
all tiny except for one big one in the middle. My (simple) testing shows it
is faster than SetLayeredWindowAttributes.
Now, do you think I have found a good solution, or is there a better way? I
understand that having common controls on a window and using
UpdateLayeredWindow can be tricky. I'm interested to know what you think.
Thanks for taking the time to respond, it was very much appreciated :)
On Jan 14, 2008 4:26 PM, Tim Roberts <timr at probo.com> wrote:
> 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.
>
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32
>
--
Henry
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-win32/attachments/20080114/21086f1a/attachment-0001.htm
More information about the python-win32
mailing list