"Steve Cookson" <steve.cook...@sca-uk.com> writes:

> Can't you use wxScreenDC?  I've never used it myself.

Neither did I...

This is how far I've got:

sub OnScreenDump {
    my ($self, $event) = @_;
    my $src = $self;
    my ( $w, $h ) = $src->GetSizeWH;
    my $bm = Wx::Bitmap->new( $w, $h, -1 );
    my $dc = Wx::WindowDC->new($src);
    my $memdc = Wx::MemoryDC->new();
    $memdc->SelectObject($bm);
    $memdc->Blit( 0, 0, $w, $h, $dc, 0, 0 );
    $memdc->SelectObject(wxNullBitmap);
    $bm->SaveFile( "scrfile.png", wxBITMAP_TYPE_PNG );
}

It is controlled from a Menu choice or shortcut key.

There are some unresolved issues, hoewever.

The screen dump is made of the applications top frame (w Wx::Frame), but
the menu bar is not included in the dump. Instead, the contents is
shifted up and the bottom 28 pixels of the png show garbage.

When I run the application in fullscreen mode there's no menu bar on the
screen and the dump covers the whole area. This is what I intend to do
anyway.

Another issue is that it is not quite WYSIWYG. It seems that sometimes
certain changes on the window are not yet part of the dump. I'm looking
into that. (Suggestions welcome)

But actually I'd expected a simple wxWidgets call to handle all this :)

-- Johan

Reply via email to