use Win32::GUI(); $text=defined($ARGV[0]) ? $ARGV[0] : "Hello, world"; $font=Win32::GUI::Font->new(-name => "Comic Sans MS", -size => 24,); $main=Win32::GUI::Window->new(-name => 'Main', -text => 'Perl'); $label=$main->AddLabel(-text => $text,-foreground => [255,0,0], -font => $font,); $ncw=$main->Width()-$main->ScaleWidth(); $nch=$main->Height()-$main->ScaleHeight(); $w=$label->Width()+$ncw; $h=$label->Height()+$nch; $desk=Win32::GUI::GetDesktopWindow(); $dw=Win32::GUI::Width($desk); $dh=Win32::GUI::Height($desk); $x=($dw-$w)/2; $y=($dh-$h)/2; $main->Move($x,$y); $main->Resize($w,$h); $main->Show(); Win32::GUI::Dialog(); sub Main_Terminate { -1; } sub Main_Resize { my $mw = $main->ScaleWidth(); my $mh = $main->ScaleHeight(); my $lw = $label->Width(); my $lh = $label->Height(); $label->Left(int(($mw - $lw) / 2)); $label->Top(int(($mh - $lh) / 2)); }