Solved

Save hDC to Bitmap

Posted on 1998-06-24
10
555 Views
Last Modified: 2013-12-03
I have a project that requires I save the contents of a Window to a .BMP file.  I have a handle to a "Compatible Bitmap", now I just need to save it to the .BMP format.

The constraints of the project will not let me use a third-party DLL or control, the program has to be delivered as a single .EXE file, therefore I need source code.

Can anyone point me to a reference in MSDN, the net, or a book which would give me this information.  Additionally, if you can recommend a low-cost (sub $50) shareware product which includes the source code in the registered version, that would be acceptable.
0
Comment
Question by:dnavarro
  • 5
  • 2
  • 2
  • +1
10 Comments
 
LVL 8

Expert Comment

by:trestan
ID: 1408537
You can find the desired software from:
http://www.mediabuilder.com/2202.html
There are both shareware and commercial software.
0
 
LVL 1

Author Comment

by:dnavarro
ID: 1408538
Thanks, but I need source code, not a shareware application.  I have to add this functionality to an existing application.
0
 
LVL 22

Accepted Solution

by:
nietod earned 50 total points
ID: 1408539
Take a look at
http://www.codeguru.com/bitmap/bitmap_to_file.shtml

ask if you have questions.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1408540
It think I gave you the wrong one

http://www.codeguru.com/bitmap/window_to_file.shtml

it more what you want.  (actually you should look at both.)
0
 
LVL 1

Author Comment

by:dnavarro
ID: 1408541
Thanks, this is exactly the answer I was looking for.  Thanks for pointing out CodeGuru to me.
0
Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

 
LVL 22

Expert Comment

by:nietod
ID: 1408542
Hey I wasn't pointing out CodeGuru!  Think of all the points I loose because of all the questions it answers!!!  :-)
0
 
LVL 10

Expert Comment

by:Lischke
ID: 1408543
Printing the visible content of a Window is actually easy, but what about printing the whole canvas including the hidden parts? What I did to accomplish that is to scroll around the window content. Anyone a better solution? BTW replace "printing" with "storing to a bitmap" and "print it on a printer" and "save it to a file" alternatively, since it's basically all the same.

Ciao, Mike
0
 
LVL 22

Expert Comment

by:nietod
ID: 1408544
It sounds like you might need to redesign your display procedures a little.  They should be able to work with any specified DC.  If you specify a window DC they display to the screen, if you specify a printer DC they print to the printer, if you specify a memory DC the draw to a bitmap for disk storage etc.
0
 
LVL 10

Expert Comment

by:Lischke
ID: 1408545
nietod, I know this, it's sometimes referred as paint-subclassing, but it always draws the visible part of the client area only. WM_PRINT should do the job, but it desn't work for some of the common controls.
0
 
LVL 22

Expert Comment

by:nietod
ID: 1408546
I didn't realize you had controls inside the client area.  I can't help there, I wrote all my own controls and they will draw to any specified DC, I'm not sure how to use the common ones in that way.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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 seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

759 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

18 Experts available now in Live!

Get 1:1 Help Now