get dc of a bitmap

  • Thread starter Thread starter climax!
  • Start date Start date
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.
 
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.
 
Back
Top