in reply to Re: win32::GUI help
in thread win32::GUI help [solved]

The code I provided is the entire program I have written. I made it only to try making a new window appear by clicking on a menu item. Later I will implement it in my main project. It's a program that searches for open reading frames in DNA sequences (bioinformatics course assignment). I thought it would be a cool addition to embed it in a user interface rather than just a plain black/white console. The code above spawns the main window with menubar. This menubar has 1 menubutton (Menu) which has 2 menu items (Quit and About). The Quit item works like it should, it closes the main window. The About item should spawn the secondary MessageBox window, but it does nothing with I click it. I later put the entire messagebox in a sub:
sub MessageBox{ my $MessageBox_About = new Win32::GUI::Window( -name => "AboutWindow", -title => "About this program", -pos =>[ 150, 150 ], -size => [150,150], -parent => $Main, ); $MessageBox_About->AddLabel( -name => "MsgBox_Label", -text => "Blabla", -pos => [20,20], ); $MessageBox_About->AddButton( -name => "MsgBox_Button", -text => "Ok", -pos => [50,40], ); $MessageBox_About->DoModal(); return 0; }
And changed MenuButton1_About to:
my $MenuButton1_About = $MenuButton1->AddMenuItem( -text => "About", -id => $Menu_id++, -onClick => MessageBox(), );
The about messagebox does appear now (A window with label Blabla and an OK button) but right at the start of the program (without clicking on the about menuitem). After clicking on Ok or terminating the window, the main window pops up. When clicking the about menuitem it gives the following error: Undefined subroutine &main::0 called at xx.pl line 127 (even though the program only has 118 lines).

Replies are listed 'Best First'.
Re^3: win32::GUI help
by thomaster (Initiate) on Oct 15, 2014 at 16:31 UTC
    Oke after browsing trough the module's demos I found the solution. I only had to change -onClick => MessageBox(), to -onClick => 'MessageBox',