If you want to do this via the event loop, the simplest way I think is:

In window:

EVT_COMMAND( $self, -1, $ID_MY_EVENT, \&mysub );

sub mysub {
  my  ($self $event) = @_;
  $self->Close;
}

Elsewhere

my $event = Wx::CommandEvent->new( $ID_MY_EVENT, -1 );
$mywindow->AddPendingEvent($event);


Thanks Mark - you are a lifesaver!

I tried to use something like "my $event = Wx::CloseEvent->new( xxx );", but couldn't figure out what to put for the params to CloseEvent - is this possible?

Incidently I still suffered small random crashes with this code and after some investigation it seems as though the AddPendingEvent runs in a threaded sense because I saw output from the rest of the code in the TaskBar event being intermingled with output from the new event set via PendingEvent. I added a Yield into the new event being triggered and this seems to have cured it (although I could have added some kind of semaphore instead I guess...)

Mattia - is it a "bug" that calling TaskBar::Destroy from within an event on the TaskBar object causes an exception in perl (at least on win32-vista - seems a bit variable under XP)?

Thanks all!

Ed W

Reply via email to