Any way to get a screenshot of the non-foreground window?

wxpython users,

Is there any way to get a snapshot of the window that is not on top? I tried
to use wxClientDC but it gets whatever is currently displayed on the screen
within the boundaries of that window, not the actual contents of the window.
E.g. if I have a message box on top of the window I am trying to get a
snapshot of, I get the image with that message box present as well.

I could not see that your question was answered over the weekend. I
apologize if I missed the reply.

In general, there is no way to do this. The contents of a partially or
totally covered window simply do not exist. Windows and X give you the
IMPRESSION of a set of full windows that stack on each other just like papers
on a desktop, but it's only a metaphor. When a window is covered by another,
the old contents are erased forever. When a hidden window is brought to the
top, the application must recreate the contents of its window from scratch.

There are certain exceptions. An X server can be configured to use "backing
store", in which your window is drawn to offscreen memory and refreshed to
the screen as needed. In that case, the full window contents are always
available. This is not commonly enabled, however, and there is no parallel
in Windows.

(One of the current discussions on the XFree86 developer's mailing list
involves this very topic. Many folks are arguing that a window should never
have to redraw itself: we have more than enough system and frame buffer
memory to keep the full contents of even complicated OpenGL windows around
forever. Thus, this situation might change in the future.)

Or, perhaps there may be a way to force an arbitrary wxWindow to paint into
a wxMemoryDC versus painting on the screen (wxPaintDC) without modifying the
window code itself? Somehow I doubt that re-writing of all the wxDC methods
will help - most controls will call the C code, ignoring all the changes in
Python.

Not in general, no. Many Windows controls create their own DCs when they
redraw themselves.

I apologize if my questions are plain dumb - I am still learning how
wxPython works.

This is not really a wxPython issue, it is a Windows or X issue. The same
thing happens with C apps.

You do not need to apologize. This is an area that is not at all obvious
when one is doing GUI programming.

···

On Fri, 22 Nov 2002 23:52:34 -0500, Vadim Bich <avbich@optonline.net> wrote:

--
- Tim Roberts, timr@probo.com
  Providenza & Boekelheide, Inc.

Thanks, Tim!

This is what I expected but was hoping anyway :slight_smile: Oh, well, at least I will
not spend any more nights trying to find a way to do what is impossible in
Windows. (I was trying to draw regular controls over an animated background
and painting everything in one window [hidden behind the second one] and
copying the contents to the second [foreground] window in OnIdle seemed like
a good way to eliminate flicker, without rewriting much of the code). That
Windows IMPRESSION has definitely fooled me :slight_smile:

P.S. This list is great place, and do not apologize, Tim, I did not really
expect any reply at all. I realize that my question is not a very usual
question.

Thanks.

···

--
Vadim

----- Original Message -----
From: "Tim Roberts" <timr@probo.com>
To: <wxPython-users@lists.wxwindows.org>
Sent: Monday, November 25, 2002 13:15
Subject: [wxPython-users] Re: Any way to get a screenshot of the
non-foreground window?

On Fri, 22 Nov 2002 23:52:34 -0500, Vadim Bich <avbich@optonline.net> wrote:
>
>wxpython users,
>
>Is there any way to get a snapshot of the window that is not on top? I

tried

>to use wxClientDC but it gets whatever is currently displayed on the

screen

>within the boundaries of that window, not the actual contents of the

window.

>E.g. if I have a message box on top of the window I am trying to get a
>snapshot of, I get the image with that message box present as well.

I could not see that your question was answered over the weekend. I
apologize if I missed the reply.

In general, there is no way to do this. The contents of a partially or
totally covered window simply do not exist. Windows and X give you the
IMPRESSION of a set of full windows that stack on each other just like

papers

on a desktop, but it's only a metaphor. When a window is covered by

another,

the old contents are erased forever. When a hidden window is brought to

the

top, the application must recreate the contents of its window from

scratch.

There are certain exceptions. An X server can be configured to use

"backing

store", in which your window is drawn to offscreen memory and refreshed to
the screen as needed. In that case, the full window contents are always
available. This is not commonly enabled, however, and there is no

parallel

in Windows.

(One of the current discussions on the XFree86 developer's mailing list
involves this very topic. Many folks are arguing that a window should

never

have to redraw itself: we have more than enough system and frame buffer
memory to keep the full contents of even complicated OpenGL windows around
forever. Thus, this situation might change in the future.)

>Or, perhaps there may be a way to force an arbitrary wxWindow to paint

into

>a wxMemoryDC versus painting on the screen (wxPaintDC) without modifying

the

>window code itself? Somehow I doubt that re-writing of all the wxDC

methods

>will help - most controls will call the C code, ignoring all the changes

in

>Python.

Not in general, no. Many Windows controls create their own DCs when they
redraw themselves.

>I apologize if my questions are plain dumb - I am still learning how
>wxPython works.

This is not really a wxPython issue, it is a Windows or X issue. The same
thing happens with C apps.

You do not need to apologize. This is an area that is not at all obvious
when one is doing GUI programming.

--
- Tim Roberts, timr@probo.com
  Providenza & Boekelheide, Inc.

---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwindows.org
For additional commands, e-mail: wxPython-users-help@lists.wxwindows.org