Hi,

Thanks for the report.
I tested the attached simple script on ActivePerl 5.14 with ppms from wxperl.co.uk and found no issues.
(Tested Windows 7 64 bit and Vista 32 + 64 bit).

Which leaves me stuck on trying to fix the problem you encountered.

If at some point you have the free time, altering the attached script so that it fails for you with wxperl.co.uk ppms would be a great help.

I appreciate that as the MSVC built ppms from ActiveState work for you you don't have a problem that needs solving right now.

Thanks

Mark

On 01/12/2011 18:55, Jiří Pavlovský wrote:
Hello,

I've been experiencing problems with Wx::ListCtrl. For example it was
freezing whenever I called FindItem.
I just find out that the problem appears in Wx from wxperl.co.uk, but
the Wx supplied with ActivePerl seems to be ok.

I believe I did not mix stuff from ActiveState and wxperl.co.uk.
I have ActivePerl 5.14 on WIndows 7.

Kind Regards,
Jiri
use strict;
use warnings;
use Wx;


package AppListCtrl;
use Wx qw( :everything );
use base qw ( Wx::ListCtrl );
use strict;
use warnings;


sub new {
	my $class = shift;
	my $self = $class->SUPER::new( @_ );
	
	$self->InsertColumn( 0, 'Item Name', wxLIST_FORMAT_LEFT, 150);
	$self->InsertColumn( 1, 'Item Extra', wxLIST_FORMAT_LEFT, 150);
	
	for(my $index = 0; $index < 1000; $index++) {
		my $id = $self->InsertStringItem($index, qq(Item $index Name));
		$self->SetItem($id, 1, $index, -1);
		$self->SetItemData($id, $index + 5000);
	}
	
	return $self;
}

package AppFrame;
use Wx qw( :everything );
use base qw( Wx::Frame );
use strict;
use warnings;
use Wx::Event qw( EVT_BUTTON );


sub new  {
	my $class = shift;
	my $self = $class->SUPER::new( @_ );
	
	my $mainpanel = Wx::Panel->new($self, -1, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE|wxTAB_TRAVERSAL);
	my $listctrl = AppListCtrl->new($mainpanel, -1, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxBORDER_NONE);
	
	my $action1 = Wx::Button->new($mainpanel, -1, 'Good Match', wxDefaultPosition, wxDefaultSize, 0);
	my $action2 = Wx::Button->new($mainpanel, -1, 'Bad Match', wxDefaultPosition, wxDefaultSize, 0);
	my $action3 = Wx::Button->new($mainpanel, -1, 'Match Data', wxDefaultPosition, wxDefaultSize, 0);
	
	$self->{list} = $listctrl;
	
	EVT_BUTTON($self, $action1, \&OnGoodMatch);
	EVT_BUTTON($self, $action2, \&OnBadMatch);
	EVT_BUTTON($self, $action3, \&OnMatchData);
	
	my $panelsizer = Wx::BoxSizer->new( wxVERTICAL );
    my $mainsizer = Wx::BoxSizer->new( wxVERTICAL );
    my $buttonsizer = Wx::BoxSizer->new( wxHORIZONTAL );
    
    $panelsizer->Add($listctrl, 1, wxEXPAND|wxALL, 0);
    
    $buttonsizer->Add($action1, 0, wxEXPAND, 3);
    $buttonsizer->Add($action2, 0, wxEXPAND, 3);
    $buttonsizer->Add($action3, 0, wxEXPAND, 3);
    
    $panelsizer->Add($buttonsizer, 0, wxALIGN_RIGHT|wxALL, 5);
    
    $mainpanel->SetSizer($panelsizer);
    $mainsizer->Add($mainpanel, 1, wxEXPAND|wxALL, 0);
    
    $self->SetSizer( $mainsizer );
    
    return $self;
}

sub OnGoodMatch {
	my ($self, $event) = @_;
	
	my $itemname = 'Item 500 Name';
	my $item = $self->{list}->FindItem(-1, $itemname);
	
	if( $item != -1 ) {
		Wx::LogMessage('%s found as id %s', $itemname, $item);
	} else {
		Wx::LogError('%s not found', $itemname);
	}
}

sub OnBadMatch {
	my ($self, $event) = @_;
	
	my $itemname = 'Item Not Exist';
	my $item = $self->{list}->FindItem(-1, $itemname);
	
	if( $item != -1 ) {
		Wx::LogMessage('%s found as id %s', $itemname, $item);
	} else {
		Wx::LogError('%s not found', $itemname);
	}
}

sub OnMatchData {
	my ($self, $event) = @_;
	
	my $data = 5745;
	my $item = $self->{list}->FindItemData(-1, $data);
	
	if( $item != -1 ) {
		Wx::LogMessage('%s found as item id %s', $data, $item);
	} else {
		Wx::LogError('%s not found in any item', $data);
	}
}


package App;
use Wx qw( :everything );
use base qw( Wx::App );
use strict;
use warnings;


sub OnInit {
	my $self = shift;
	my $mwin = AppFrame->new(undef, -1, "ListCtrl FindItem Test");
	$self->SetTopWindow($mwin);
	$mwin->Show(1);
	return 1;
}


package main;

my $app = App->new();
$app->MainLoop();

1;







    



Reply via email to