Hi,
How do I convert a Win32 hbrush to a .Net brush object?
A lot of the .Net objects have things like FromHfont and FromHRgn but i
can't find the equivalent for a brush...
Many thanks,
Kieron
Kevin Westhead - 18 Sep 2003 19:11 GMT
> How do I convert a Win32 hbrush to a .Net brush object?
>
> A lot of the .Net objects have things like FromHfont and FromHRgn but i
> can't find the equivalent for a brush...
I'm not sure that you can do this directly, but you should be able to create
a new System.Drawing.*Brush based on your HBRUSH; this effectively means
recreating the brush so it's not very efficient.
You'll need p/invoke definitions for the GetObject method (gdi32) and the
LOGBRUSH structure. You can then call GetObject with your HBRUSH as the GDI
object and use a LOGBRUSH as your buffer. Once you have the LOGBRUSH you can
examine it to work out what specific type of System.Drawing.Brush you need
and create a new instance of that type.

Signature
Kevin Westhead