Hi all,

I'm trying to do a printing engine for Windows using win32ui and win32gui, and I stumbled on a problem: the graphics to print may contain random paths, that may have to be filled with a gradient. So I browsed the docs and found win32gui.GradientFill, which does gradients indeed, but only seems to work for triangles or rectangles (according to http://msdn.microsoft.com/en-us/library/dd144957(VS.85).aspx). So far so good: filling the bounding rectangle for a path and clipping it to the path contents is basically what I want, so I tried to find a way to set the clipping region to a random path.

This is where my problem is: methods or functions to handle the clipping region exist in win32ui and win32gui, and I seem to need a few of both: - Since neither the SelectClipPath function, nor the SelectClipPath method on CDC objects seem to have been made available through pywin32, it seems my only option is to build the clipping region from the current path. - There is indeed a function PathToRegion in win32gui, which seems to do what I want. Problem: it uses handles as its parameters and return values, and I already have a lot of things that use win32ui, and the objects it defines: PyCDC, PyCRgn, and so on… I also need some methods on PyCDC objects that I haven't found in win32gui (namely StartDoc, StartPage, EndPage, EndDoc). - So I searched for a way to convert or copy objects between the 2 representations. I found one for getting the handle for PyCDC objects (GetHandleOutput) and it seems to work indeed: I can do a win32gui.PathToRegion(my_pycdc.GetHandleOutput()), which returns a handle on the region built from the current path, or so I think. - Since I have to pass the region to my_pycdc.SelectClipRgn, which only accepts PyCRgn objects, I now need a way to convert the handle on the region to a PyCRgn. And this is where I'm stuck: I indeed found a conversion function at C++ level (CRgn::FromHandle, http://msdn.microsoft.com/en-us/library/s0w0kk5s.aspx) , but it doesn't seem to be exposed via the Python API. I tried to add a new method to PyCRgn objects allowing to use this method, but got a lot of compilation errors that I couldn't figure out (I'm far from being a Windows programming expert…) and couldn't get anything usable.

In the current state of pywin32, is there any way to achieve what I'm trying to do? If not, can anybody help me adding my method to the PyCRgn object? It's basically a clone of CopyRgn using CRgn::FromHandle instead of PyCRgn::GetRgn to get the region to copy.

Thanks!
 - Eric -

_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to