Hiya Jez,

I agree that a Win32::GUI cookbook would be a great idea, available as a
document that you can print out and read, while being able to download an
electronic copy, to enable the 'cutting & pasting' of examples.

To ease editing, add styles and colour coding, a MS Word document would
probably be the most common format. It can then be read in Star Office, and
a PDF version could also be output.

I'm happy to do some assembly... and make a 'work-in-progress' version
available via a link on my domain.

Once we have got to various stages we can commit it to CVS on sourceforge.

Unless someone else with a degree in publishing, a Mac with Quark and
nothing else to do, wishes to volunteer...

Otherwise, start emailing me content/examples...

Chris Wearn

-----Original Message-----
From: Jez White [mailto:[EMAIL PROTECTED]
Sent: Monday, 15 November 2004 06:59
To: Glenn Linderman; Chris Wearn
Cc: Win32-GUI List
Subject: Re: [perl-win32-gui-users] Website - Code snippets gallery


>> There are many examples / small snippets of code that could serve as
>> examples to others, we just need a place to easily store and collectively
>> showcase them. Something like a forum (I run one using phpBB). Is there
>> any
>> way of doing this on Sourceforge or some other place where people can
>> paste
>> in 'how to' snippets, or do we start one.

I too think we need a place for these snippets - a Win32::GUI cookbook of
sorts. It's a question of who is prepared to maintain/organise it? Any
offers?

> It is always delightful when someone offers some of the hard-won fruits of
> their labors to share with others.  Thanks for thinking of it.
>
> This is probably a nice snippet of code... but it isn't complete enough to
> run, so I can't tell for sure.  Probably adding a few lines at the top to
> use strict; use warnings; use Win32::GUI; and to initialize the

I've created an example, and have added to CVS - the code is also below. The
only thing you need to do is to have a bitmap of some description - I was
going to add a bitmap to CVS so the script would run, but I don't think the
world is ready for my art skills:)

Cheers,

jez.

-------------
use Win32::GUI;
use strict;

my ($width,$height);
my $mainwin;

#try to load the splash bitmap from the exe that is running
my $splashimage= new Win32::GUI::Bitmap('SPLASH');
unless ($splashimage) {
  #bitmap is not in exe, load from file
  $splashimage= new Win32::GUI::Bitmap('SPLASH.bmp');
  die 'could not find splash bitmap' unless $splashimage;
  #get the dimensions of the bitmap
  ($width,$height)       = $splashimage->Info();
  }

#create the splash window
my $splash     = new Win32::GUI::Window (
   -name       => "Splash",
   -text       => "Splash",
   -height     => $height,
   -width      => $width,
   -left       => 100,
   -top        => 100,
   -addstyle   => WS_POPUP,
   -popstyle   => WS_CAPTION | WS_THICKFRAME,
   -addexstyle => WS_EX_TOPMOST
);

#create a label in which the bitmap will be placed
my $bitmap    = $splash->AddLabel(
    -name     => "Bitmap",
    -left     => 0,
    -top      => 0,
    -width    => $width,
    -height   => $height,
    -bitmap   => $splashimage,
);
$bitmap->SetImage( $splashimage );

#center the splash and show it
$splash->Center;
$splash->Show();
#call do events - not Dialog - this will display the window and let us
#build the rest of the application.
Win32::GUI::DoEvents;

#A good way of building your application is to keep everything in packages,
and eval those
#into scope in this phase. In this case, we'll create the main window and
sleep to simulate
#some work.
my $string = q `
               $mainwin     = new Win32::GUI::Window (
               -name       => "Main",
               -text       => "Main window",
               -height     => 400,
               -width      => 400,
                );
                sleep(2);
                $mainwin->Center();
                $mainwin->Show();
               `;
#eval the code and report any errors
eval $string;
if ($@) {
  my $message = $@;
  Win32::GUI::MessageBox($splash, $message ,"Build Error", MB_OK |
MB_ICONWARNING);
  }
#hide the splash and enter the Dialog phase
$splash->Hide;
Win32::GUI::Dialog();




Reply via email to