get dc of a bitmap

C

climax!

Hi!

I am writing a custom scrollbar which will be partly transparent(for a
PDA - so cf.net, .net has a gethdc() method) Everthing runs ok, I
imported some functions from the gdi(like transparentimage() etc)...
but i can't find a way to get a DC from a Bitmap object(loaded from
resources) which is necessary for the gdi methods. Now, I thought about
displaying the bitmap in a hidden control(child window), take its hwnd
and then get it's DC... this should work but seems not to be a very
elegant solution. Does anybody has an other idea?

thanx.
 
D

Dmytro Lapshyn [MVP]

Hi,

Not sure about the PDAs, but in regular Windows, a bitmap cannot have a DC -
all it can have is an HBITMAP handle (or, in .NET Framework terms, it should
be simply a Handle). To paint a bitmap on a DC (that is, a Graphics object),
you must create a compatible DC (regular .NET Framework 1.1 can create a
Graphics object from an image for you with the use of the FromImage method).
Or, even simpler, you can use the Graphics.DrawImage method.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top