Hey everyone:

I want to copy the way say window1 is currently displayed (in terms of
what has been painted).
This is becauase I now need to call a command that will send window1 to
all black.
Now I want to paste in the way window1 looked, which I have copied in
step1.

Please tell me there's a nice & easy way to do this,

`Chase (membos AT yahoo DOT com)

Re: Copy window contents to repaint another window by William

William
Thu Apr 13 09:29:12 CDT 2006

<daveparkinson@gmail.com> wrote in message
news:1144886411.973151.184110@g10g2000cwb.googlegroups.com...
> I want to copy the way say window1 is currently displayed (in terms of
> what has been painted).

If you are asking you can you create a bitmap, say, from a window, so that
you could then print it or display it, oe redisplay it someehere else, then
the MS sample WinCap (for window capture) demonstrates the Graphics Device
Interface (GDI) functions that you would need to use:

http://support.microsoft.com/kb/q97193/

> This is because I now need to call a command that
> will send window1 to all black.

I don't know what you mean. If the window is yours, just paint its client
area with a black brush. If it is not, what you want to do is nasty at both
the user and technical levels.

> Now I want to paste in the way window1 looked, which
> I have copied in step1.

Paste to the clipboard? If so, you create a bitmap of the image you want to
paste and call (assuming that your application owns the clipboard)
SetClipboardData().

If on the other hand, what you are really trying to do is take over the
painting for a window that is not yours then you are in for an awful lot of
work.

Regards,
Will





Re: Copy window contents to repaint another window by JustBoo

JustBoo
Thu Apr 13 14:53:07 CDT 2006

On 12 Apr 2006 17:00:12 -0700, daveparkinson@gmail.com wrote:
>I want to copy the way say window1 is currently displayed (in terms of
>what has been painted).

Here is admittedly a SWAG. (Sophisticated Wild-Ass Guess) :-)

Get the Display Context (DC) of the window you have been drawing in
and pass it to the other window and just paint that window with the
first windows DC. (Of course, do this before you turn the first window
black.) You could think of it as a kooky way to do double-buffering.

Caveat: I have never done this before and have no idea how many
arcane, convoluted, hard to find bugs this might cause. That's if it
even compiles and/or runs. :-)

"Go on, prove me wrong. Destroy the fabric of the universe. See if I
care." - Terry Pratchett

Re: Copy window contents to repaint another window by William

William
Thu Apr 13 14:57:54 CDT 2006

"JustBoo" <JustBoo@BooWho.com> wrote in message
news:that329v5fgeileee72h4vs9tjuo78ecaf@4ax.com...
> Get the Display Context (DC) of the window you have been drawing in
> and pass it to the other window and just paint that window with the
> first windows DC. (Of course, do this before you turn the first window
> black.) You could think of it as a kooky way to do double-buffering.

The DC is clipped so that painting does not overrun to the window.

The problem with shenanigans like these is that the original window
procedure is oblivious to the change. As soon as Windows sends it a WM_PAINT
message, whatever you thought you put there is gone.

Regards,
Will



Re: Copy window contents to repaint another window by JustBoo

JustBoo
Thu Apr 13 15:29:49 CDT 2006

On Thu, 13 Apr 2006 15:57:54 -0400, "William DePalo [MVP VC++]"
<willd.no.spam@mvps.org> wrote:
>"JustBoo" <JustBoo@BooWho.com> wrote in message
>news:that329v5fgeileee72h4vs9tjuo78ecaf@4ax.com...
>> Get the Display Context (DC) of the window you have been drawing in
>> and pass it to the other window and just paint that window with the
>> first windows DC. (Of course, do this before you turn the first window
>> black.) You could think of it as a kooky way to do double-buffering.
>
>The DC is clipped so that painting does not overrun to the window.
>
>The problem with shenanigans like these is that the original window
>procedure is oblivious to the change. As soon as Windows sends it a WM_PAINT
>message, whatever you thought you put there is gone.

Windows Subclassing?

BOOL CDC::Attach( HDC hDC );

Remember, I'm not being very serious about this. It's just an
intellectual exercise. Please let's not have someone get their Daisy's
In A Bunch over this.

"The philosophy exam was a piece of cake which was a
bit of a surprise, actually, because I was expecting
some questions on a sheet of paper."

Re: Copy window contents to repaint another window by William

William
Thu Apr 13 17:07:40 CDT 2006

"JustBoo" <JustBoo@BooWho.com> wrote in message
news:1mbt32lap6df32997flkorcfmke30ns84s@4ax.com...
>>The problem with shenanigans like these is that the original window
>>procedure is oblivious to the change. As soon as Windows sends it a
>>WM_PAINT
>>message, whatever you thought you put there is gone.
>
> Windows Subclassing?

That's an option. It's a lot of work.

> BOOL CDC::Attach( HDC hDC );

No. This just associates a Win32 device context with an instance of an MFC
class that "wraps" the DC. The trouble is that if the DC was "from" the
original window you can't use it to paint outside of that window.

> Remember, I'm not being very serious about this.

I know. :-)

> Please let's not have someone get their Daisy's
> In A Bunch over this.

Musing is fine. Thinking out loud is fine. Unworkable proposals need to be
identified as such.

Regards,
Will