Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

#18 Parts method for Status Bar Control

closed-fixed
Steve Pick
None
2
2004-02-16
2004-02-15
Anonymous
No

I've found a bug when using the parts method in the
status bar control. All the following statements fail (no
error, application just exits):

$status->Parts($width-200,$width-100,-1);
my $temp=$status->Parts($width-200,$width-100,-1);
my @temp=$status->Parts($width-200,$width-100,-1);

While the following works:

print $status->Parts($width-200,$width-100,-1);
foreach ($status->Parts($width-200,$width-100,-1))
{print "$_ \n";}

Example:

use Win32::GUI;
use strict;

my $W = new GUI::Window(
-title => "Win32::GUI::status test",
-left => 100,
-top => 100,
-width => 300,
-height => 200,
-name => "main",
-onResize => \&main_resize
);

my $status=$W->AddStatusBar(-name => "Status");

$status->Parts(50,100,-1);
$status->PartText(0,'Lots of text');
$status->PartText(1,'Part 1');
$status->PartText(2,'Part 2');

$W->Show;

Win32::GUI::Dialog;

sub main_resize {
$status->Width($W->ScaleWidth);
$status->Top($W->ScaleHeight - $status->Height);
my $width=$status->Width;
#The following work:
print $status->Parts($width-200,$width-100,-1);
#foreach ($status->Parts($width-200,$width-100,-1))
{print "$_ \n";}
#The following fail:
#$status->Parts($width-200,$width-100,-1);
#my $temp=$status->Parts($width-200,$width-100,-1);
#my @temp=$status->Parts($width-200,$width-100,-
1);

}

Discussion

  • Steve Pick
    Steve Pick
    2004-02-16

    Logged In: YES
    user_id=690817

    Fixed in CVS - the problem was parts returns a list with -1 as
    the last element, causing -1 to be assigned to $_, and then
    be returned by the handler. This was not a bug with Parts(),
    but with the code given (it should explicitly return 0).
    However Parts has been updated so that it returns the
    number of parts in scalar context, instead of a list in scalar
    context.

    Steve

     
  • Steve Pick
    Steve Pick
    2004-02-16

    • priority: 5 --> 2
    • assigned_to: nobody --> theweevil
    • status: open --> closed-fixed