Solved

HICON from CBitmap

Posted on 1998-11-15
2
1,161 Views
Last Modified: 2013-12-03
If I have a CBitmap, how do I get/convert it to a HICON.
0
Comment
Question by:jubjub
2 Comments
 

Author Comment

by:jubjub
ID: 1416105
I'll give some more info..  Basically I have a DC where I'm doing some Drawing.  I want to get the Bitmap.  Easy enough.  But then I want to get a HICON.  Handle to the Icon Data.  
There has to be an easy way of doing this...  With the HICON, i can use to do what ever I want, like saving to an ICO file..for example, of drawing to the SysTray..etc  etc  etc
0
 
LVL 8

Accepted Solution

by:
Answers2000 earned 50 total points
ID: 1416106
Declare a CImageList

use Create member to add create the image list empty

use Add member to add CBitmap to the image list

use ExtractIcon member to obtain an image of the n'th item in the image list


BTW
1. You can get the size req'd for an icon using ::GetSystemMetrics( SM_CXICON or SM_CYICON)

2. If the original bitmap is the wrong size, create a 2 nd memory bitmap with is the correct size and StretchBlt from the first to the second, and Add the 2nd memory bitmap to the image list

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
DataAdapter, stored procedures and parameters 2 44
Table Size and Indexes in SQL Server 6 21
Issue when running a SSIS package (.dts) from an SQL job 21 82
Need more details 5 128
This article shows a few slightly more advanced techniques for Windows 7 gadget programming, including how to save and restore user settings for your gadget and how to populate the "details" panel that is displayed in the Windows 7 gadget gallery.  …
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now