From: Jouke V. <jo...@pv...> - 2001-10-10 13:19:27
|
Hi, I can't find a successful way to draw on the screen using some kind of DC other than in an OnPaint or OnDraw method. I want to draw to a piece of the screen from outside of those methods. The following examplecode executes without errors or warnings, but shows an empty window: Any ideas why? #!/usr/bin/perl use strict; use Wx; package MyApp; use base qw(Wx::App); sub OnInit { my $this = shift; my $frame = MyFrame->new( undef, 'Blah', [50,50], [420, 300] ); $frame->Show(1); $this->SetTopWindow( $frame ); $frame->Maximize(1); return 1; } package MyFrame; use base qw(Wx::Frame); use Wx qw(wxWHITE wxBITMAP_TYPE_GIF wxDEFAULT wxNORMAL wxFONTENCODING_ISO8859_1); sub new { my $class = shift; my $this = $class->SUPER::new( $_[0], -1, @_[1,2,3] ); Wx::InitAllImageHandlers(); # create a scrolledwindow (canvas) $this->{PANEL} = Wx::ScrolledWindow->new($this, -1); $this->{PANEL}->SetBackgroundColour( wxWHITE ); $this->{PANEL}->Show(1); # Initialize the DC my $dc = Wx::ClientDC->new($this->{PANEL}); $this->{PANEL}->PrepareDC($dc); # create bitmap my $bmp = Wx::Bitmap->new("h:/pABC/SOURCES/Plaatjes-syntheseprogr/SOK.gif", wxBITMAP_TYPE_GIF); my $image = Wx::Image->new($bmp); $image->Rescale(200, 200); $bmp = $image->ConvertToBitmap(); $dc->DrawBitmap($bmp, 250, 0, 0); # draw some text my $font = Wx::Font->new(100, wxDEFAULT, wxNORMAL, wxNORMAL, 0, "", wxFONTENCODING_ISO8859_1); $dc->SetFont($font); $dc->DrawText("S O _", 250,225); return $this; } package main; my $app = MyApp->new(); $app->MainLoop(); -- *-----------------------------------------------* |Jouke Visser |jo...@pv... | |Perl GUI Geek |http://www.pvoice.org | *-----------------------------------------------* PS: Notice new mailaddress!! |