Solved

printing an HICON

Posted on 2004-10-13
4
429 Views
Last Modified: 2011-09-20
For some reason I just can't get my HICON to print.  I can print an image loaded via LoadImage to print via GetDIBits and StretchDIBits but my icon refuses to work.  The code to do this would be a huge help, I have been trying for days.
I have been playing about with
GetIconInfo( iconExtracted, &IconInfo32x32);
GetObject( IconInfo32x32.hbmColor  , sizeof(BITMAP), &Bmp);
I end up with a BITMAP object, all I might need is the code to get the handle of the BITMAP object.
0
Comment
Question by:horrid
  • 2
4 Comments
 
LVL 13

Accepted Solution

by:
SteH earned 500 total points
Comment Utility
The handle used in GetObject is the first parameter. I guess you need to do a bitblt of the icon bitmap into a bitmap created of the correct size for your icon (32x32 pixels).
0
 
LVL 12

Expert Comment

by:OnegaZhang
Comment Utility
the following may be useful to you
http://www.fruitfruit.com/vc/release/post/print.htm

0
 

Author Comment

by:horrid
Comment Utility
wow, after 3 days I just replaced the HICON reference witt IconInfo32x32.hbmColor as directed by SteH and bingo..works first go.  The white background area did print as black but I am happy to overlook that.

And thanks OnegaZhung, nice example.  I have bookmarked that one for future use.
0
 
LVL 13

Expert Comment

by:SteH
Comment Utility
You might be able to use the mask bitmap to get the background to white. Bitblt or MaskBlt the mask to the image to change the background color to white. I am not sure what raster operation you will need. Either do some experiments or post a reduced mask and icon bitmap. In principle this should be done when displaying an icon/cursor as well.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

728 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

9 Experts available now in Live!

Get 1:1 Help Now