thomaster has asked for the wisdom of the Perl Monks concerning the following question:
Then making the first window and include the menuuse strict; use Win32::GUI(); my $Menu_id=1; my $Menu = new Win32::GUI::Menu(); my $MenuButton1 = $Menu->AddMenuButton( -text => "Menu", -id => $Menu_id++, ); my $MenuButton1_Quit = $MenuButton1->AddMenuItem( -text => "Quit", -id => $Menu_id++, -onClick => sub{print"program closed\n"; return -1;}, ); my $MenuButton1_About = $MenuButton1->AddMenuItem( -text => "About", -id => $Menu_id++, -onClick => $MessageBox_About->DoModal(), );
Then the messagebox showing the about info. Since there is no actual MessageBox() I just made a window with a label and a close buttonmy $Main = new Win32::GUI::Window( -name => "MainWindow", -title => "Main Window", -pos => [ 100, 100 ], -size => [ 300, 200 ], -menu => $Menu, ); $Main->AddLabel( -name => "Label1", -text => "Welcome", -pos => [12,10], );
The problem here of course is that $MessageBox doesn't exist yet when it's called at the MenuButton1 onClick event. The messagebox has the main window as parent and DoModal is used to prevent interaction in the main window while the about window is still visible. I tried an event handler submy $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], ); sub MsgBox_Button_Click {return -1;} #closes the messagebox
But also doesn't work.. How to get this to work?sub MenuButton1_About_Click{$MessageBox_About->DoModal(); return 0;}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: win32::GUI help
by dasgar (Priest) on Oct 15, 2014 at 06:27 UTC | |
by thomaster (Initiate) on Oct 15, 2014 at 11:39 UTC | |
by thomaster (Initiate) on Oct 15, 2014 at 16:31 UTC | |
|
Re: win32::GUI help
by Anonymous Monk on Oct 14, 2014 at 19:14 UTC |