Andrew M Pastuszak wrote:
I am having a problem, with the progress bar not displaying in a window.
Here is my subroutine. Feel free to offer any comments you want about
cleaning up this code:
Without *short*, *complete*, and *runnable* code example that
demonstrates your problem it is very difficult to help. In making your
code example runnable I end up with something that runs fine.
Here's what I cut your code down to:
#!perl -w
use strict;
use warnings;
use Win32::GUI();
my $progress = Win32::GUI::Window->new(
-title => 'Conversion Progress',
-name => 'Progress',
-size => [450,125],
);
$progress->AddProgressBar(
-name => 'PB',
-size => [400,20],
-pos => [0,20],
);
$progress->AddStatusBar(
-name => 'SB',
);
$progress->PB->SetRange(0,100);
$progress->Center();
$progress->Show();
foreach (1 .. 100) {
$progress->PB->SetPos($_);
$progress->SB->Text("$_");
#Win32::GUI::DoEvents(); # See later in email
Win32::Sleep(100);
}
$progress->Hide();
exit(0);
__END__
As I said, it runs fine, and the progress bar is displayed. The only
thing that I can see that you might want to do is add a
Win32::GUI::DoEvents() call during the loop, so that all windows
messages get processed - otherwise things like paint messages are not
handled (try moving another window across the front of the progress
window, while it is running).
Regards,
Rob.