hi,
in the code below i use a CheckListBox and a TreeCtrl; i fill the
CheckListBox with values 1..100 with the sub FillCheckBox in the package
myTreeCtrl; when i run the app and click into the CheckListBox the
program will abort because of a memory-access-violation. sometimes this
happens at the first click inside, sometimes it takes some more. i get
the same error when having marked an item in the CheckListBox and
pressing spacebar. i'm working under Win2000, perl v5.6.0 from
ActiveState and wxPerl 0.07. can anyone help me ?
regards
paul
############################
use Wx;
package myFrame;
use strict;
use vars qw(@ISA);
@ISA = qw(Wx::Frame);
my ($ID_QUIT,$ID_CHKLISTBOX) = ( 1 .. 10 );
use Wx qw(:treectrl :window :sizer
wxDefaultPosition wxDefaultSize wxLB_MULTIPLE wxLB_HSCROLL
wxLB_NEEDED_SB wxLB_SORT);
sub new {
my $class = shift;
my $this = $class->SUPER::new( undef, -1, $_[0], [ @_[1, 2] ],
[ @_[3, 4] ] );
$this->SetIcon( Wx::GetWxPerlIcon() );
my $sizer1 = Wx::BoxSizer->new( wxHORIZONTAL);
$this->{CHECKLISTBOX} =
Wx::CheckListBox->new($this, $ID_CHKLISTBOX, wxDefaultPosition,
wxDefaultSize, [],
wxLB_MULTIPLE|wxLB_HSCROLL|wxLB_NEEDED_SB|wxLB_SORT);
$this->{TREECTRL} =
myTreeCtrl->new($this->{CHECKLISTBOX}, $this, -1, wxDefaultPosition,
wxDefaultSize,
wxTR_HAS_BUTTONS|wxTR_EDIT_LABELS|wxSUNKEN_BORDER);
$sizer1->Add($this->{TREECTRL}, 2, wxGROW);
$sizer1->Add($this->{CHECKLISTBOX}, 1, wxGROW);
$this->SetSizer($sizer1);
$this->SetAutoLayout(1);
my $file = Wx::Menu->new;
$file->Append($ID_QUIT, "E&xit" );
my $bar = Wx::MenuBar->new;
$bar->Append($file, "&File");
$this->SetMenuBar( $bar );
use Wx::Event qw(EVT_MENU EVT_UPDATE_UI);
EVT_MENU($this, $ID_QUIT, \&OnQuit);
$this;
}
sub OnQuit {
my( $this, $event ) = @_;
$this->Close( 1 );
}
#######################################
package myTreeCtrl;
use strict;
use vars qw(@ISA);
@ISA = qw(Wx::TreeCtrl);
sub new {
my $class = shift;
my $listbox = shift;
my $this = $class->SUPER::new( @_ );
$this->{CHECKLISTBOX} = $listbox;
$this->FillCheckBox($listbox);
$this;
}
sub FillCheckBox {
my ($this, $listbox) = @_;
for (my $i = 0; $i < 100; $i++) {
$listbox->Append($i);
}
}
#######################################
package myApp;
use strict;
use vars qw(@ISA);
@ISA = qw(Wx::App);
sub OnInit {
my $this = shift;
my $frame = myFrame->new("Window", 50, 50, 450, 450);
$frame->Show(1);
$this->SetTopWindow($frame);
1;
}
#######################################
package main;
my $app = myApp->new;
$app->MainLoop;
#######################################
|