Daniel wrote:
Hi all,I have a bitmap defined like this: Wx::InitAllImageHandlers(); #load the image my $wxbitmap = Wx::Bitmap->new('c:\work\car.jpg',wxBITMAP_TYPE_JPEG); $wxbitmap->SetWidth(400); $wxbitmap->SetHeight(300); #Get a dc object my $drawArea = Wx::ClientDC->new($panel_image); #Draw the bitmap $drawArea->DrawBitmap($wxbitmap,0,0,0); #Register the painting event Wx::Event::EVT_PAINT( $panel_image, sub { my ($self, $event) = @_; my $drawArea; if (defined $event) { $drawArea = Wx::PaintDC->new($self); } else { $drawArea = Wx::ClientDC->new($self ); } #DRAW STUFF IN HERE! (eg. previous code for drawing a bitmap) $drawArea->DrawBitmap($wxbitmap,20,70,0); if (defined $event) { $event->Skip(); } }); This works fine. Now I wanted to use a BoxSizer: $panel_image->{BoxSizer}{"midleft"} = Wx::BoxSizer->new(wxVERTICAL); $panel_image->{BoxSizer}{"midleft"}->Add($drawArea, 0, wxALL|wxALIGN_CENTER, 20); But this causes an error: unable to resolve overloaded method for Wx::Sizer::Add What am I doing wrong? Adding other things (textboxes, buttons etc.) is no problem.
You can't add a device context to a sizer, because a DC is not a window. You can create a panel, add the above paint event to it and add the panel to the sizer. Or you can just use a wxStaticBitmap. HTH Mattia
