From: Marcus <li...@wo...> - 2002-04-15 11:30:55
|
I'm using Wx::Html. Everything works fine until you exit the program and you get an exception error. If you comment out "LoadPage" in the HTMLPage package below, then the error does not occur, but the HTML window is created fine. I'm guessing something is still open in Wx::HTML, but if so what? It may be something else of course. Using wxPerl 0.10 on MSW with ActivePerl 623. Here is the code (created in part by wxDesigner, but no code relating to Wx::HTML is in the _wdr.pl file). use strict; use Wx; use Wx::Html; # Get the full path use FindBin; use lib $FindBin::RealBin; sub filename { "$FindBin::RealBin/" . $_[0] } # Read resource do 'html_wdr.pl'; # constants # WDR: classes # Load HTML page package HTMLPage; use strict; use vars qw(@ISA); @ISA = qw(Wx::HtmlWindow); use Wx qw(wxID_OK wxID_CANCEL); sub new { my( $class ) = shift; my( $this ) = $class->SUPER::new( @_ ); $this->LoadPage(main::filename( 'html/index.html' ) ); # WDR: handler declarations for HTMLPage $this; } # WDR: methods for HTMLPage # WDR: handler implementations for HTMLPage sub OnLinkClicked { my( $this, $link ) = @_; # Show user the URL Wx::LogMessage( 'Link clicked: href="%s"', $link->GetHref() ); # Now go to link. This causes LoadPage to use "$link" $this->SUPER::OnLinkClicked( $link ); } package MyFrame; use strict; use vars qw(@ISA); @ISA=qw(Wx::Frame); use Wx::Event qw(EVT_MENU EVT_CLOSE EVT_SIZE EVT_UPDATE_UI); use Wx qw(wxOK wxICON_INFORMATION wxTB_HORIZONTAL wxNO_BORDER); sub new { my( $class ) = shift; my( $this ) = $class->SUPER::new( @_ ); $this->CreateMyMenuBar(); $this->CreateStatusBar( 1 ); $this->SetStatusText( "Welcome!", 0); # insert main window here my ($html) = HTMLPage->new( $this, -1 ); # WDR: handler declarations for MyFrame EVT_MENU( $this, $main::ID_ABOUT, \&OnAbout ); EVT_MENU( $this, $main::ID_QUIT, \&OnQuit ); EVT_CLOSE( $this, \&OnCloseWindow ); $this; } # WDR: methods for MyFrame sub CreateMyMenuBar { my( $this ) = shift; $this->SetMenuBar( &main::MyMenuBarFunc() ); } # WDR: handler implementations for MyFrame sub OnAbout { my( $this, $event ) = @_; Wx::MessageBox( "Welcome to SuperApp 1.0\n(C)opyright Joe Hacker", "About SuperApp", wxOK|wxICON_INFORMATION, $this ); } sub OnQuit { my( $this, $event ) = @_; $this->Close(1); } sub OnCloseWindow { my( $this, $event ) = @_; $this->Destroy(); } package MyApp; use strict; use vars qw(@ISA); @ISA=qw(Wx::App); sub OnInit { my( $this ) = @_; Wx::InitAllImageHandlers(); my( $frame ) = MyFrame->new( undef, -1, "SuperApp", [20,20], [500,340] ); $frame->Show(1); 1; } package main; my( $app ) = MyApp->new(); $app->MainLoop(); |