Perl Basics
Introduction to Perl
FAQ's
CGI
Regular Expressions

PC Overview
Cool Stuff
My Modules
Success Stories
Links
Perl in the News
Logos

PC Internals
About
Contact
Handy Logos
What's new

Win32::GUI

Windows GUI Programming with Win32::GUI
See also
P-friendly

[ home ] - [ search ] - [ sitemap ]


See also [ perl/GUI-Programming/index.html ]

processinfo.pl

Download [ processinfo.pl ] - [ bitmap.pl ]

Screen Shot


ListView Sample

[ Find more examples at http://jeb.ca/perl/win32-gui-docs/index.pl/code_samples ]

Screen Shot


A Hello, World! Example with Win32::GUI

#!/usr/bin/perl -w
use strict;

use Win32::GUI;

# -- GLOBAL
my $main;
my $label;
my $ncw;
my $NCH;

&main();

sub main() {
	
	my $text = defined($ARGV[0]) ? $ARGV[0] : "Hello, world";

	$main = Win32::GUI::Window->new(
		-name => 'Main',
		-text => 'Perl',
	);
	my $font = Win32::GUI::Font->new(
		-name => "Comic Sans MS",
		-size => 24,
	);
	$label = $main->AddLabel(
		-text => $text,
		-name => 'label',
		-font => $font,
		-foreground => [255, 0, 0],
	);

	$ncw = $main->Width() -  $main->ScaleWidth();
	$NCH = $main->Height() - $main->ScaleHeight();
	my $w = $label->Width()  + $ncw;
	my $h = $label->Height() + $NCH;

	my $desk = Win32::GUI::GetDesktopWindow();
	my $dw = Win32::GUI::Width($desk);
	my $dh = Win32::GUI::Height($desk);
	my $x = ($dw - $w) / 2;
	my $y = ($dh - $h) / 2;

	$main->Change(-minsize => [$w, $h]);
	$main->Move($x, $y);
	$main->Show();

	Win32::GUI::Dialog();
}

sub Main_Terminate {
	-1;
}

sub Main_Resize {
	my $w = $main->Width();
	my $h = $main->Height();
	my $lw = $label->Width();
	my $lh = $label->Height();
	if ($lw > ($w - $ncw)) {
	    $main->Width($lw + $ncw); # Remember the non-client width!
	}
	else {
	    $label->Left(($w - $ncw - $lw) / 2);
	}
	if ($lh > ($h - $NCH)) {
	    $main->Height($lh + $NCH); # Remember the non-client height!
	}
	else {
	    $label->Top(($h - $NCH - $lh) / 2);
	}
}

[ Find more examples at http://jeb.ca/perl/win32-gui-docs/index.pl/code_samples ]

home - feedback - search

$Id: foo.htm,v 1.10 2004/03/11 17:50:01 reto Exp $
© 1998-2004 reto :)