The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: Bieb on March 09, 2005, 09:52:24 PM

Title: hWnd to BMP?
Post by: Bieb on March 09, 2005, 09:52:24 PM
What's the easiest way to get the contents of a window (a static control, to be exact) into a bitmap file?
Title: Re: hWnd to BMP?
Post by: petezl on March 10, 2005, 10:50:42 AM
Hi Bieb,
Get the windows dc for the static:
GetClientRect of Static and use measurements to create a Compatible (monochrome) bitmap.
Use GetClientRect of Static and use measurements to create a Compatible DC
Select the bitmap into it.
BitBlt the static into the Comaptible dc.
Call your BMP file creation process.
Peter.
Title: Re: hWnd to BMP?
Post by: Bieb on March 10, 2005, 11:23:51 AM
What I mean is,  how do you create the bitmap file?  Is there an API function to do it?
Title: Re: hWnd to BMP?
Post by: Tedd on March 10, 2005, 12:25:19 PM
I'm not sure there is. (Unless you look into the COM stuff - IPicture?)

But it's pretty simple to just write your own directly to file.
- Write header (standard, with a few options for bmp size and number of colours, etc)
- Write palette (silly ordering, but simple enough)
- Write contents (they're stored upside-down :eek)
Title: Re: hWnd to BMP?
Post by: Bieb on March 10, 2005, 01:43:05 PM
Well then, I guess I'll look up the format and then write my own library for it.  Thanks for the help.
Title: Re: hWnd to BMP?
Post by: kero on March 10, 2005, 01:50:45 PM
Hi, Bieb

This DoubleSnapFromPoint.zip contains source,
hope it'll help you


[attachment deleted by admin]