The MASM Forum

General => The Campus => Topic started by: gelatine1 on November 13, 2014, 02:28:52 AM

Title: store the current window output before clearing it in the WM_BACKGROUND message
Post by: gelatine1 on November 13, 2014, 02:28:52 AM
Is it possible to retrieve the current ouput in the window to use somewhere later ?
Title: Re: store the current window output before clearing it in the WM_BACKGROUND message
Post by: TouEnMasm on November 13, 2014, 03:08:53 AM

Output text,Image ?
If it is an image,copy it in a Hdc
If it is text,send a message WM_GETTEXT (or something like that)


Title: Re: store the current window output before clearing it in the WM_BACKGROUND message
Post by: Tedd on November 13, 2014, 05:28:45 AM
Do it in the same way you'd use a back buffer, but swap the roles of the two DCs -- create a memory DC to store the window contents, then BitBlt the contents of the window DC to it.

Alternatively, if you're already using a back buffer, there's no need because the window contents are already in the back buffer, so you can just re-blt them when needed.
Title: Re: store the current window output before clearing it in the WM_BACKGROUND message
Post by: gelatine1 on November 13, 2014, 05:15:11 PM
But don't I need to use BeginPaint first to use those device contexts ? and I thought beginpaint sends a message to WM_BACKGROUND to erase the background ? :/
Title: Re: store the current window output before clearing it in the WM_BACKGROUND message
Post by: dedndave on November 13, 2014, 11:12:42 PM
no, and no
you do not need to use BeginPaint, unless you are responding to WM_PAINT

the OS sends WM_ERASEBKGND before sending WM_PAINT
that is, unless you use a method that prevents it - I like to use hbrBackground = NULL in the window class

you can get the DC - then copy the contents into another DC
what I suggest, for making a bitmap, is CreateDIBSection (rather than CreateCompatibleBitmap)
select the DIB section into the mem DC and copy the contents using BitBlt (or perhaps, StretchBlt)
once you have the data in a DIB section, it's fairly simple to create a BMP file from it