How to convert HICON to HBITMAP in VC++?

I don't have code readily available to share, but I think this is pretty easy. You have to create the HBITMAP, create a device context, select the bitmap into the DC (this will make the bitmap the drawing area for this DC). Finally call the DrawIcon() function to draw your icon on this DC.

After that detach the bitmap from the DC and destroy the DC. Your bitmap now should be ready to go.

I don't have code readily available to share, but I think this is pretty easy. You have to create the HBITMAP, create a device context, select the bitmap into the DC (this will make the bitmap the drawing area for this DC). Finally call the DrawIcon() function to draw your icon on this DC.

After that detach the bitmap from the DC and destroy the DC. Your bitmap now should be ready to go. Update after looking at your code: I believe the problem is in the createCompatibleBitmap call.

You are asking for a bitmap compatible with the memory DC, but memory DCs start with a 1 bit/pixel bitmap selected into them. Try asking for a bitmap compatible with the screen DC instead. Update 2: you may want to look at this question as it seems related to your problem.

I'm doing the same thing but the resulting bitmap is always 1bit/pixel. So strange....... – Paul Dinh Sep 10 at 22:15 1 Please expand your question with sample code. Sounds like your bitmap was not created with the right bits/pixel, but can't say for sure without looking at the code.

– Miguel Sep 10 at 22:16 added the code, the DC created from screen so it's supposed to be 32bit/pixel, pls have a look.... – Paul Dinh Sep 10 at 22:24 1 I have updated my answer, give that a try and let me know if it helps! – Miguel Sep 10 at 23:03 1 See the link I've added to the question, it may be of help. – Miguel Sep 10 at 23:20.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions