ChrisR has asked for the wisdom of the Perl Monks concerning the following question:
I have tried using $mainform = Win32::GUI::DialogBox->new(-name=>'main',-text=>'tabframe test',-width=>800,-height=>600,-dialogui=>1); to create the main window but it has no effect.#!c:\perl\bin\wperl.exe use strict; use Win32::GUI; use Win32::GUI::TabFrame; my $mainform; $mainform = Win32::GUI::Window->new(-name=>'main',-text=>'tabframe tes +t',-width=>800,-height=>600,-dialogui=>1); $mainform->AddTabFrame(-name=>"tab",-panel=>"Page",-width=>770,-height +=>550,-left=>10,-top=>10,-addstyle=>WS_TABSTOP); $mainform->tab->InsertItem(-text=>" Tab1 ",-border=>0,top=>10,-addstyl +e=>WS_TABSTOP); $mainform->tab->Page0->AddTextfield(-name=>'tab0_text1', -text=>'tab0_ +text1', -left=>200, -top=>10, -height=>24, -width=>80,-tabstop=>1); $mainform->tab->Page0->AddTextfield(-name=>'tab0_text2', -text=>'tab0_ +text2', -left=>200, -top=>40, -height=>24, -width=>80,-tabstop=>1); $mainform->tab->Page0->AddTextfield(-name=>'tab0_text3', -text=>'tab0_ +text3', -left=>200, -top=>70, -height=>24, -width=>80,-tabstop=>1); $mainform->tab->InsertItem(-text=>" Tab2 ",-border=>0,top=>10,-addstyl +e=>WS_TABSTOP); $mainform->tab->Page1->AddTextfield(-name=>'tab1_text1', -text=>'tab1_ +text1', -left=>200, -top=>10, -height=>24, -width=>80,-tabstop=>1); $mainform->tab->Page1->AddTextfield(-name=>'tab1_text2', -text=>'tab1_ +text2', -left=>200, -top=>40, -height=>24, -width=>80,-tabstop=>1); $mainform->tab->Page1->AddTextfield(-name=>'tab1_text3', -text=>'tab1_ +text3', -left=>200, -top=>70, -height=>24, -width=>80,-tabstop=>1); $mainform->tab->InsertItem(-text=>" Tab3 ",-border=>0,top=>10,-addstyl +e=>WS_TABSTOP); $mainform->tab->Page2->AddTextfield(-name=>'tab2_text1', -text=>'tab2_ +text1', -left=>200, -top=>10, -height=>24, -width=>80,-tabstop=>1); $mainform->tab->Page2->AddTextfield(-name=>'tab2_text2', -text=>'tab2_ +text2', -left=>200, -top=>40, -height=>24, -width=>80,-tabstop=>1); $mainform->tab->Page2->AddTextfield(-name=>'tab2_text3', -text=>'tab2_ +text3', -left=>200, -top=>70, -height=>24, -width=>80,-tabstop=>1); $mainform->Show(); Win32::GUI::Dialog(); exit; main_Terminate { $mainform->Hide(); return -1; }
package Win32::GUI::TabFrame; my $VERSION = "0.02"; use Win32::GUI; use Win32::GUI::Frame; @ISA = qw(Win32::GUI::TabStrip); my %Instance = {}; # # new # sub new { my $class = shift; my $parent = shift; my %options = @_; my $panel = "Panel"; # Default Panel Name $panel = $options{-panel} if exists $options{-panel}; # New TabStrip my $self = new Win32::GUI::TabStrip ($parent, %options); # Init instance variable $self->{'#LastPanel'} = 0; $self->{'#Panel'} = $panel; # Keep object reference $Instance{$options{-name}} = $self; # Add Click Event eval qq( sub main::$options{-name}_Click { return Win32::GUI::TabFrame->ClickEvent($options{-name}); } ); return bless $self, $class; } # # AddSSTab # sub Win32::GUI::Window::AddTabFrame { return Win32::GUI::TabFrame->new(@_); } # # DisplayArea # sub DisplayArea { my $self = shift; my ($left,$top,$right,$botton) = $self->AdjustRect($self->GetClien +tRect()); return ($left, $top, $right - $left, $botton - $top); } # # Insert Element # sub InsertItem { my $self = shift; my %options = @_; # Add a panel my $count = $self->Count(); my $name = $self->{'#Panel'}.$count; my $border = 0; my $text = ""; if (exists $options{-border}) { $border = $options{-border} } if (exists $options{-paneltext}) { $text = $options{-paneltext} } my ($x,$y,$width,$height) = $self->DisplayArea(); #following line added by ChrisR to resolve display issue if($count == 0){$y=$y+18;$height=$height-18;} my $panel = $self->AddFrame ( -name => $name, -text => $text, -pos => [$x, $y], -size => [$width, $height], -border => $border, ); # Only show first page $panel->Hide() unless ($count == 0); # Add TabStrip $self->SUPER::InsertItem(%options); return $panel; } # # Resize # sub Resize { my $self = shift; my $width = shift; my $height = shift; $self->SUPER::Resize ($width, $height); my ($ax,$ay,$awidth,$aheight) = $self->DisplayArea(); my $count = $self->Count(); for ($i = 0; $i < $count; $i++) { my $page = $self->{'#Panel'}.$i; $self->{$page}->Move ($ax , $ay); $self->{$page}->Resize($awidth, $aheight); } } # # Reset : # sub Reset { my $self = shift; my $count = $self->Count(); for ($i = 0; $i < $count; $i++) { my $page = $self->{'#Panel'}.$i; $self->{$page}->DestroyWindow(); } $self->{'#LastPage'} = 0; return $self->SUPER::Reset(); } # # DeleteItem : # sub DeleteItem { die "Win32:GUI::TabFrame : Methode DeleteItem not working"; } # # ClickEvent # sub ClickEvent { my $class = shift; my $name = shift; my $element = $Instance{$name}; my $page = $element->{'#Panel'}.$element->{'#LastPanel'}; # Hide Last Page $element->{$page}->Hide(); # Show New Page $element->{'#LastPanel'} = $element->SelectedItem(); $page = $element->{'#Panel'}.$element->{'#LastPanel'}; $element->{$page}->Show(); } 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Help with tabstops in Win32::GUI
by jplindstrom (Monsignor) on Apr 14, 2005 at 14:25 UTC | |
by ChrisR (Hermit) on Apr 14, 2005 at 20:11 UTC | |
by jplindstrom (Monsignor) on Apr 15, 2005 at 13:41 UTC |