I'm sure I'm overlooking something obvious but I've banged my head on the keyboard for long enough. Below I've included a small test case to demonstrate my dilemma.
Its a simple script that displays a dialog window which contains a single button. Clicking the button or the 'close app' icon (small 'X' on the title bar) should end the program run.
It works as expected until I uncommment the package declaration line. At that point the button clicks are no longer recognized and using the 'close app' icon only hide()'s the window and doesn't properly call the *_Terminate function.
Is there something I'm doing wrong or is it an issue with Win32::GUI accessing package level items even though the session was initiated from the same package?
-Nitrox
#package gui_test;
use strict;
use warnings;
use Win32::GUI;
display_gui();
exit;
sub btnCancel_Click {-1;}
sub Main_Terminate {-1;}
sub display_gui {
my $main = Win32::GUI::DialogBox ->new(
-name => "Main",
-text => "GUI Test",
-width => 200,
-height => 200,
-top => 200,
-left => 200,
);
my $btn_cancel = $main->AddButton(
-name => "btnCancel",
-cancel => 1,
-text => "Cancel",
-left => 100,
-top => 100,
);
$main->Show();
Win32::GUI::Dialog();
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.