>Robert wrote
> Then insert the $content in the Win32::GUI control you want.
>For a Textfield that would be
>$textfield->Text($content);
>undef $content; # unless you really want the text stored twice
Thank you...
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?
(http://perl-win32-gui.sourceforge.net/docs/Win32/GUI/Reference/Methods.
html) And not specifically on the Win32::GUI::Textfield entry..? (ie,
every control that CAN access/manipulate text does so this-a-way..) If
so, thanks. If not, I'm still searching... ;>)
Here's the code I've borrowed up this point (mostly from the
tutorial.) When I run it, I do not see the text box, referenced by
<$textstuff> (populated or not)... Any help much appreciated.
Is there a beginners win32::gui list? ;>)
Mark
------------------------------------------------------------------------
---------------------------------
use strict;
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;
$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);
$textstuff->Text($content);
undef $content;
$main->Show();
#Win32::GUI::Dialog();
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);
}
-----------------------------------------------------------