I posted this example to the list not that long ago. I've since
corrected it so that it doesn't leave ugly lines all over the place.
Regards,
Rob.
#!perl -w
use strict;
use warnings;
use Win32::GUI;
my $mw = Win32::GUI::Window->new(
-title => "Splitter Test",
-pos => [100,100],
-size => [500,400],
-onResize => \&main_resize,
);
$mw->AddTextfield(
-name => "TF1",
-multiline => 1,
-width => 200,
);
$mw->AddSplitter(
-name => "SP",
-left => 200,
-width => 5,
-onRelease => \&do_splitter,
);
$mw->AddTextfield(
-name => "TF2",
-multiline => 1,
-left => 200 + $mw->SP->Width(),
);
$mw->Show();
Win32::GUI::Dialog();
exit(0);
# NEM splitter event gets 2 parameters. The first (as always)
# is the window object the event came from - in this case the
# splitter window; The second depends on the splitter orientation:
# if horzontal it is the top coordinate; if vertical it is
# the left coordinate. (coordinates relative to the parent's
# client area)
# The splitter window is moved by the splitter object, so you only
# have to re-position your other windows
sub do_splitter
{
my ($splitter, $coord) = @_;
$mw->TF1->Width($coord);
$mw->TF2->Left($coord+$mw->SP->Width());
# Swap these next 2 lines to see the 'bug' come back
#$mw->TF2->Width($mw->ScaleWidth()-$mw->SP->Width());
$mw->TF2->Width($mw->ScaleWidth()-$mw->SP->Width()-$coord);
}
sub main_resize
{
my $self = shift;
$self->TF1->Height($self->ScaleHeight());
$self->SP->Height($self->ScaleHeight());
$self->TF2->Resize($self->ScaleWidth()-$self->TF1->Width()-$self->SP->Width(),
$self->ScaleHeight());
}
__END__
A. Pollock wrote:
I built a simple Win32::GUI application which connects to an
Access database containing hierarchical records and builds
a tree view out of them. Now I would like to extend the
application so that clicking on a record in the tree in the
right-hand pane will display the record details in a left
hand pane. Try as I might, I can nowhere find any example
program that uses a moveable splitter to separate a Window
into panes or "frames."
Can anybody give me a simple example showing how to set up
frames in Win32:GUI and put something in them? I'm an idiot
without examples to guide me.
Thanks!
_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs