Mark Sutfin wrote:
I installed 1.02 (5.8.7). I still cannot locate the Text()
method in the Win32::GUI:Textfield entry.
Could it be that I'm so new to this, I didn't understand that
it's listed on the "Common Methods" entries?

You're absolutely correct.

Is there a beginners win32::gui list? ;>)

This is the right place - the community it's big enough for lost of lists (yet :-)

#!perl -w
use strict;
use warnings;

Always good to have as many warnings as possible


    use Win32::GUI;

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

    my $main = Win32::GUI::Window->new(
                -name => 'Main',
                -text => 'Perl',
                -width => 200,
                -height => 200
        );
my $sb = $main->AddStatusBar(); $sb->Text("This appears in the status bar"); my $font = Win32::GUI::Font->new( -name => "Comic Sans MS", -size => 24,
        );
    my $label = $main->AddLabel(
                -text => $text,
                -font => $font,
                -foreground => [255, 0, 0],
        );

    my $ncw = $main->Width() -  $main->ScaleWidth();
    my $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;
I think
$main->Center(Win32::GUI::GetDesktopWindow());
can replace all the code you have to calculate where the center is.

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

    my $file_path = Win32::GUI::GetOpenFileName(
                - directory => "c:\\"
        );
my $content;
    {
    local $/;
    open(FILE, $file_path) or die "Failed to open $file_path: $!";
    $content = <FILE>;
    close FILE;
    }
my $textstuff = Win32::GUI::Textfield->new($main, -multiline => 1);
You need to give the Textfield a size. It (helpfully) initialises with width and height of 0. So it's there, but you can't see it.
Try
my $textstuff = $main->AddTextField(
        -size => [100,100],
        -multiline => 1,
        -vscroll => 1,
);

    $textstuff->Text($content);
    undef $content;

    $main->Show();
#Win32::GUI::Dialog();
Any reason you have your Dialog() call commented out?


    sub Main_Terminate {
        -1;
    }

    sub Main_Resize {
        my $w = $main->ScaleWidth();
        my $h = $main->ScaleHeight();
        my $lw = $label->Width();
        my $lh = $label->Height();
                $label->Left(int(($w - $lw) / 2));
                $label->Top(int(($h - $lh) / 2));
        $sb->Move(0, $main->ScaleHeight - $sb->Height);
$sb->Resize($main->ScaleWidth, $sb->Height); }

Regards,
Rob.

Reply via email to