I have created a Window with a tapstrip and placed buttons on the tapstrip
pages. When I click a tabpage, then click a button on that page, I hoped the
button click event for that button would fire, but it does not. Is this a
bug in Win32::GUI or is there a trick I need to learn?
If you run the below program, and click the SUBMIT button below the
textfield, a messagebox should pop up but it does not?
Thanks,
Eric
use Win32::GUI;
$Font = new Win32::GUI::Font(
-name => "Courier New",
-size => 12,
-weight => 700,
-height => -14,
);
$LFont = new Win32::GUI::Font(
-name => "Courier New",
-size => 16,
-weight => 700,
-height => -17,
);
$SFont = new Win32::GUI::Font(
-name => "Courier New",
-size => 8,
-weight => 700,
-height => -11,
);
$W = new GUI::Window(
-title => "Bank Of America Print & Edit Application",
-left => 150,
-top => 50,
-width => 475,
-height => 500,
-font => $Font,
-name => "Window",
);
$TS = $W->AddTabStrip(
-left => 0,
-top => 0,
-width => $W->ScaleWidth,
-height => $W->ScaleHeight,
-name => "Tab",
-font => $Font,
);
$TS->InsertItem(-text => "Main"); # tab 0
$TS->InsertItem(-text => "Header"); # tab 1
$TS->InsertItem(-text => "Trailer"); # tab 2
$TS->InsertItem(-text => "Detail"); # tab 3
#######################################
# OBJECTS FOR TABSTRIP PAGE 0 (Main) #
#######################################
$Print_l = $TS->AddLabel(-name => "Print_l",
-text => "Print Invoice",
-left => 115,
-top => 43,
-height => 20,
-align => left,
-width => 150 );
$Print = $TS->AddButton(-name => "Print",
-text => "SUBMIT",
-left => 10,
-top => 39,
-height => 25,
-width => 73 );
$SubTitle_l = $TS->AddLabel(-name => "SubTitle_l",
-font => $LFont,
-text => "View and Edit Transaction File",
-left => 85,
-top => 84,
-height => 25,
-align => left,
-width => 350 );
$Header_l = $TS->AddLabel(-name => "Header_l",
-text => "Header Record",
-left => 115,
-top => 133,
-height => 20,
-align => left,
-width => 150 );
$Header = $TS->AddButton(-name => "Header",
-text => "SUBMIT",
-left => 10,
-top => 129,
-height => 25,
-width => 73 );
$Trailer_l = $TS->AddLabel(-name => "Trailer_l",
-text => "Trailer Record",
-left => 115,
-top => 176,
-height => 20,
-align => left,
-width => 150 );
$Trailer = $TS->AddButton(-name => "Trailer",
-text => "SUBMIT",
-left => 10,
-top => 172,
-height => 25,
-width => 73 );
$PhoneNo_l = $TS->AddLabel(-name => "PhoneNo_l",
-text => "Detail Record",
-left => 115,
-top => 219,
-height => 20,
-align => left,
-width => 250 );
$PhoneNo = $TS->AddTextfield(-name => "PhoneNo",
-text => "Phone No.",
-font => $SFont,
-left => 10,
-top => 215,
-height => 20,
-width => 90 );
$PhoneNo->MaxLength(10);
$PhoneNo->SetFocus();
$PhoneNo->Select(0,length($PhoneNo->Text()));
$Detail = $TS->AddButton(-name => "Detail",
-text => "SUBMIT",
-left => 10,
-top => 240,
-height => 25,
-width => 73 );
#########################################
# OBJECTS FOR TABSTRIP PAGE 1 (Header) #
#########################################
##########################################
# OBJECTS FOR TABSTRIP PAGE 2 (Trailer) #
##########################################
#########################################
# OBJECTS FOR TABSTRIP PAGE 3 (Detail) #
#########################################
#########################
# INITIALIZATION #
#########################
$prevtabid=-1;
$TS->Select(0);
Open_EditFile();
$W->Show();
$W->BringWindowToTop();
Tab_Click();
#########################
# GUI EVENT HANDLER #
#########################
Win32::GUI::Dialog(); # logical end of program is here
#############################
# NON-EVENT SUBROUTINES #
#############################
sub Open_EditFile {
@PATHARRAY=split(/\\/,$0); # split pathfilename by \ delimiter into an
array
$perlname=$PATHARRAY[$#PATHARRAY]; # name of this perl script without
path
$editname="BankofAmer.txt"; # name of the file to edit
$file=$0; # $0 is the full pathfilename of this perl script
$file=~s/$perlname/$editname/; # do the name substitution
open(FILE,"+< $file"); # open for read/write access
$stat=seek(FILE,0,0); # attempt to position file pointer at top of file
if ($stat != 1) {
close(FILE);
Win32::GUI::MessageBox($dummy,"Can't position file pointer.
Aborting.",
"Bank Of America Print & Edit Application - Status",16,);
exit;
}
}
#################################
# GENERAL EVENT SUBROUTINES #
#################################
sub Window_Resize {
$TS->Resize($W->ScaleWidth, $W->ScaleHeight);
}
sub Window_Terminate {
close(FILE);
return -1;
}
sub Tab_Click {
$tabid=$TS->SelectedItem();
if ($prevtabid == 0) {
$Print->Hide();
$Print_l->Hide();
$SubTitle_l->Hide();
$Header->Hide();
$Header_l->Hide();
$Trailer->Hide();
$Trailer_l->Hide();
$PhoneNo_l->Hide();
$PhoneNo->Hide();
$Detail->Hide();
} elsif ($prevtabid == 1) {
$dummy=1;
} elsif ($prevtabid == 2) {
$dummy=1;
} elsif ($prevtabid == 3)
$dummy=1;
} else {
$dummy=1;
}
if ($tabid == 0) {
$Print->Show();
$Print_l->Show();
$SubTitle_l->Show();
$Header->Show();
$Header_l->Show();
$Trailer->Show();
$Trailer_l->Show();
$PhoneNo_l->Show();
$PhoneNo->Show();
$Detail->Show();
} elsif ($tabid == 1) {
$dummy=1;
} elsif ($tabid == 2) {
$dummy=1;
} elsif ($tabid == 3)
$dummy=1;
} else {
$dummy=1;
}
$prevtabid=$tabid;
}
################################################
# TABSTRIP PAGE 0 (Main) EVENT SUBROUTINES #
################################################
sub Detail_Click {
Win32::GUI::MessageBox($W,"Just A Test",
"Bank Of America Print & Edit Application - Status",64,);
}
##################################################
# TABSTRIP PAGE 1 (Header) EVENT SUBROUTINES #
##################################################
###################################################
# TABSTRIP PAGE 2 (Trailer) EVENT SUBROUTINES #
###################################################
##################################################
# TABSTRIP PAGE 3 (Detail) EVENT SUBROUTINES #
##################################################