[EMAIL PROTECTED] wrote:
I do have a concrete example (given below).
Behavior:
1. A window containing a list view w/caption and scroll bar is displayed.
No it's not. There's no scrollbars in your example.
2. On clicking the terminate ('X') in the list view I expect
that my list view terminate sub (ReportBox_Terminate) will be called.
Hmm. I've never seen anyone trying that combination of styles on a
child window. I'm pretty surprised it works at all. If you're looking
for an MDI (multiple-document interface) style application then you
should be investigating Win32::GUI::MDI. I've never used this, so can't
help. There's an example in the demos directory that I've already
pointed you at.
3. The ReportBox_Terminate subroutine is never called (the print statement
is not executed).
OK. I have *NO* idea what the expected behaviour would be for the
example you've given.
What should the event handler name be (<object name>_<event name>) so that
termination of the list box will cause the event handler to be invoked?
Why do you want to terminate the listbox?
#! /bin/perl
Surely not?
#! C:\Perl\bin\perl.exe -w
or something similar?
use Win32::GUI ( WS_BORDER # Exporter doesn't seem to correctly
, WS_CAPTION # export values given in GUI.pm
, WS_CHILD # @EXPORT = qw( );
, WS_SYSMENU,
, WS_VISIBLE
); # Thin binding to Win32 GUI
use Win32::GUI;
exports everything OK here.
use strict; # Strict checking pragma
good!
use integer; # Computations done using integer arithmetic
why?
use warnings;
excellent!
my $window;
my $ListBox; # Output report listing
sub MainWnCreate;
sub myWindow_Terminate;
sub ReportBox_Terminate;
#----------------------------------------------------------
# MainWnCreate
#----------------------------------------------------------
sub MainWnCreate{
$window = new Win32::GUI::Window(
-name => "myWindow",
-title => "VAX to PC Realignment",
-left => 300, #0
-top => 200, #0
-width => 320,
-height => 240,
);
$ListBox = $window->AddListbox(
-disabled => 0,
-name => "ReportBox",
-pos => [ 100, 40 ],
-size => [ 100, 100 ],
-style => 1024 | WS_BORDER | WS_CAPTION | WS_SYSMENU,
As above, I've no idea what adding caption and sysmenu styles to a child
window does. What window style is 1024?
-title => "Report",
-visible => 0
Not needed.
);
} ### MainWnCreate
sub myWindow_Terminate {
print "myWindow_Terminate\n";
return -1;
} ### myWindow_Terminate
sub ReportBox_Terminate{
print "ReportBox_Terminate\n";
return 1;
}
#----------------------------------------------------------
# Main-
#----------------------------------------------------------
&MainWnCreate;
$window->Show();
$ListBox->Show();
Wouldn't be needed if you didn't set the visibility to 0 when creating
the control (child windows are not displayed unless their parents are
visible, hence Win32::GUI creates main windows with -visibility => 0 and
child windows with -visibility = 1 by default. Then you only need to
show/hide the main window.
Win32::GUI::Dialog();
How about this:
#!perl -w
use strict;
use warnings;
use Win32::GUI (); # Don't need any imports, as we don't use them
# Create the main window
my $window = new Win32::GUI::Window(
-name => "myWindow",
-title => "VAX to PC Realignment",
-pos => [300,200],
-size => [320,240],
);
# add a list box as a child of the main window,
# size it to fit the main window
$window->AddListbox(
-name => "ReportBox",
-size => [ $window->ScaleWidth(),
$window->ScaleHeight() ],
);
# show the window, and enter the dialog phase
$window->Show();
Win32::GUI::Dialog();
# done
exit(0);
# on resize of main window, resize listbox to
# fill mainwindow
sub myWindow_Resize {
$window->ReportBox->Resize(
$window->ScaleWidth(),
$window->ScaleHeight(),
);
return 1;
}
# Terminate.
sub myWindow_Terminate {
return -1;
}