I had the, maybe bad, idea of putting up a kind of "framework", so I
could manage my windows definitions in external separate files.
In its simplest form it works as expected:
<code>
#!/usr/bin/perl -w
use strict;
use Win32::GUI qw(WS_SYSMENU);
my $handle = do 'mainw.gui' ;
$handle->Show;
Win32::GUI::Dialog();
</code>
But I also wanted to build this around some objects.
So I added a package returning an object.
Now it still appeared to work, but on exit I get some error messages
like:
(in cleanup) Can't call method "DELETE" on an undefined value ...
First, I can't understand what the undefined value is.
(But it clearly has to do with the exported constants.)
Second - can I just disregard this message? Should I do it in some other
way? Or should I drop the whole idea?
The version I am using is ActiveState Perl 5.8.8 build 819
with Win32::GUI version 1.0304
Some code to show the error:
#!/usr/bin/perl -w
package NC::GUI;
use strict;
use Carp;
#use Win32::GUI();
# uncomment line above and
# out-comment the line below to make error disappear
use Win32::GUI qw(WS_SYSMENU); # any constant will do
sub new {
my $class = shift;
$class = ref($class) || $class;
my $self = {};
bless $self, $class;
return $self;
}
sub read_form {
my ($self, $filename) = @_;
# read a file containing definitions for a window
$self->{form}->{$filename}->{window} = do $filename ;
}
sub run {
my ($self, $name) = @_;
$self->{form}->{'mainw.gui'}->{window}->Show;
Win32::GUI::Dialog();
}
1;
#-----------------------------------------------------------------------
--
package main;
use strict;
my $obj = new NC::GUI;
$obj->read_form('mainw.gui');
$obj->run();
__END__
#-- And the external file mainw.gui contains:
$mainW = new GUI::DialogBox(
-name => "mainWindow",
-title => "Our main window",
-left => 100,
-top => 100,
-width => 130,
-height => 230,
);
$mainW->AddButton(
-name => "mainButton1",
-text => "Dummy",
-valign => "center",
-left => 70,
-top => 164,
-width => 40,
);
# return handle
$mainW;
#--- end of mainw.gui ---
Thanks for any insights,
Leif