Hi Jez. I found the problem (duh...) You should remember that Parts also returns the widths of all parts as a list. Since you have a part of width -1 on the last part, when you call Parts a list with -1 as the last element is being returned. In the instances you showed where Parts does not work, $_ is being set to -1 by your code. For example, $status->Parts(10,20,-1); would set $_ to -1. Then when the function just runs off the end, the contents of $_ is returned, and if you return -1 from a function in win32::gui, the event loop ends. So to solve your problem, get into the habit of explicitly returning from your functions. It's a very good habit to be in and can stop a lot of bugs appearing, especially in Win32::GUI. Also, I've committed an update for the statusbar Parts method that will check if it's in Scalar context and if so returns the number of parts instead of a list of parts. This will also fix your problem. Steve
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Jez White Sent: 15 February 2004 10:08 To: Win32-GUI Subject: [perl-win32-gui-users] Status bar Parts method bug. Hi, 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";} See example below. I've created a task in the tracker. Cheers, jez. ===================================== 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); }