how do i save the content of a hdc(handle device context) to a file

This is a discussion on how do i save the content of a hdc(handle device context) to a file within the Windows Programming forums, part of the Platform Specific Boards category; how do i save the content of a hdc(handle device context) to a file. I have captured the screen and ...

First off get familiar with the structure of a bitmap file. Check out www.wotsit.org for more info. Anyway first you have to use GetObject to load the HDCs properties into an HBITMAP. From there you create your BITMAPINFO structure. Next you get the size of your image data bits (the size will be your biSizeImage and use GetDIBits to get the data), create your BITMAPFILEHEADER then write them to a file in order (BITMAPFILEHEADER, BITMAPINFO (BITMAPINFOHEADER/color table) and image data.