Save hDC to Bitmap

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.
LVL 1
dnavarroAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
nietodConnect With a Mentor Commented:
Take a look at
http://www.codeguru.com/bitmap/bitmap_to_file.shtml

ask if you have questions.
0
 
trestanCommented:
You can find the desired software from:
http://www.mediabuilder.com/2202.html
There are both shareware and commercial software.
0
 
dnavarroAuthor Commented:
Thanks, but I need source code, not a shareware application.  I have to add this functionality to an existing application.
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
nietodCommented:
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
 
dnavarroAuthor Commented:
Thanks, this is exactly the answer I was looking for.  Thanks for pointing out CodeGuru to me.
0
 
nietodCommented:
Hey I wasn't pointing out CodeGuru!  Think of all the points I loose because of all the questions it answers!!!  :-)
0
 
LischkeCommented:
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
 
nietodCommented:
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
 
LischkeCommented:
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
 
nietodCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.