Drawing wx.Window on MemoryDC

Hello,

I'm not sure wheter I should ask this in wxpython-users or wx-users,
but here it goes..

I've been stuck for the last few hours attempting to store in a bitmap
(selected into a MemoryDC) what a Panel and its children would look
like had it been requested by, say, an OnPaint event.

I can create a ClientDC linked to the aforementioned panel and perform
a blit to memory, however this only works right if the panel is shown
on screen completely undisturbed by scrolling, clipping or
overlapping. Given how the panel is in most cases far taller than the
screen and inside a wx.ScrolledWindow, this provides very little use.

I've attempted to remove clipping regions, but that doesn't affect
whatever's already inside of the ClientDC.

My question is, how can I induce the native renderers of wx.Window
objects to draw themselves using a different DC? Is this possible? If
not, is there a way to circumvent this with some terribly obscure but
genius code?

Thanks for your time.

-F

Federico Ceccatto wrote:

My question is, how can I induce the native renderers of wx.Window
objects to draw themselves using a different DC? Is this possible?

I'm pretty sure it's not possible. As wx wraps the native widgets, they are drawing themselves to the native screen -- you can't intercept that process.

> If

not, is there a way to circumvent this with some terribly obscure but
genius code?

I think the only option is to blit from a clientDC or WindowDC, but, as you've found, what that gives you is exactly what's on the screen, which apparently isn't good enough for your needs. Darn.

-Chris

···

--
Christopher Barker, Ph.D.
Oceanographer
                                         
NOAA/OR&R/HAZMAT (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception

Chris.Barker@noaa.gov

Federico Ceccatto wrote:

My question is, how can I induce the native renderers of wx.Window
objects to draw themselves using a different DC? Is this possible? If
not, is there a way to circumvent this with some terribly obscure but
genius code?

I experimented a few years ago with ways to provide this functionality but was never really successful. There is some support for it on Windows, but not all of the native controls implement what is needed to make it work, and when XP themes were introduced then it got even more finicky. I'm pretty sure that there is a way to make it work on OS X, but I never got that far, and I never could find anything on GTK that would either give me the buffer a widget is drawn to, or allow me to tell a widget to draw itself to some other buffer.

I think my experimental code for MSW is still in wxPython if you want to try it out. It's a function called wx.DrawWindowOnDC(window, dc), but please remember that it is experimental and could break or vanish at any point.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!

Thanks for the info, much appreciated.

Unfortunately this has to work on GTK so I guess I'll be using a
simpler graphical effect. It was just a fancy pull-down, pull-up
effect for a FoldPanelBar-like widget.