Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / September 2003

Tip: Looking for answers? Try searching our database.

HBRUSH->System.Drawing.Brush...??

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Kieron Lanning - 18 Sep 2003 14:50 GMT
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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.