Hi

I am trying to send myself a CommandEvent type object based on the the samples here:
http://www.gigi.co.uk/wxperl/pdk/perltrayexample.txt
http://search.cpan.org/dist/Wx/lib/Wx/Thread.pod

(However, ideally for neatness I would like to be able to send myself a non command event, specifically in this case I want to send a Close message to one of my windows. How would I achieve this?)

What I have so far is a sub which does:

   my $canary = Wx::Window::FindWindowById($main::WX_ID_CANARY, undef);
   my $e = Wx::PlEvent->new( -1, $main::ID_MENU_FILE_EXIT );
Wx::PostEvent( $canary, $e );
Then in the canary window I have:

   EVT_COMMAND( $this, -1, $main::ID_MENU_FILE_EXIT, \&OnClose );

But sub OnClose is never called? What am I doing wrong? "$canary" is definitely set ok because I can call $canary->OnClose() - (however, this causes a crash due to another problem)

I also tried using Wx::PlCommandEvent and also WxCloseEvent, but neither seems to reach my destination window?

FWIW: the reason I am doing this is that I am finding lots of problems getting wxPerl apps to exit cleanly from the TaskBar object. Calling TaskBar->Destroy() from within an event on the taskbar seems to be an automatic crash in the perl executable (under win32 at least). So if I want to exit my app from a popup menu in the systemtray then I think that I need to send myself a close event and do all the destruction in the main app rather than the taskbar object.

Grateful for some pointers

Ed W

Reply via email to