Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: win32::GUI help

by dasgar (Priest)
on Oct 15, 2014 at 06:27 UTC ( [id://1103889]=note: print w/replies, xml ) Need Help??


in reply to win32::GUI help [solved]

You may want to look at Win32::GUI's tutorial part 5's section on modal windows. That should help you figure out what you may have wrong with your code.

As for providing more specific help, it's kind of hard to do that. You've provided code snippets, but not the full set of code. I've got a suspicion on what might be one thing that could potentially cause problems, but can't say for sure without seeing your full code.

Also, you say that it "doesn't work", but you don't provide details. What doesn't work? What is being displayed? Are there error messages?

If you can provide a full set of code (preferably a minimum amount of code to reproduce the issue) along with more description of what the problem is (including error messages), that would make it easier for others to try to reproduce what your seeing and provide more exact suggestions on fixing your code. Otherwise, you'll probably will just be getting general recommendations, such as pointers to Win32::GUI documentation.

Replies are listed 'Best First'.
Re^2: win32::GUI help
by thomaster (Initiate) on Oct 15, 2014 at 11:39 UTC
    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).
      Oke after browsing trough the module's demos I found the solution. I only had to change -onClick => MessageBox(), to -onClick => 'MessageBox',

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1103889]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2024-03-28 19:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found