Moore, Paul wrote:
>Given a Win32::GUI object, I want to get at the value of an option (eg,
>a control's height). How do I do this? For example, given a main window
>$main, can I get its width (given that the user may have resized it)?

print $main->Width();

>Second question - can I set a window/control's options (again, width and
>height are the obvious examples) in code?

$main->Change( %options );

>Actually, after a bit of digging, I found $current = $win->Width() and
>$win->Width($newval). So it's a documentation issue :-)

I agree it's not really obvious. we still lack a decent user's guide.
feel free to make your contribution here.

>Actually, I'd like
>
>    [...]
>
>to work (ie, to dynamically resize the main window based on the text),
>but it doesn't. Any chance of that?

there's a little concept to introduce here: the difference between window 
area and client area. a window size (given with ->Height and ->Width) 
is not really the inner area of the window, that you can use to place
controls, because it has some non-client areas (namely, a titlebar, 
a border, and eventually a menubar).
controls (like labels), on the other side, do not have non-client area 
to cope with.
the client area of a window is given by the ->ScaleWidth and 
->ScaleHeight methods, so your sample should be written as:

    use Win32::GUI;
    $main = new Win32::GUI::Window(-name =>"Main");
    $main->AddLabel(-name => 'Label1', -text => "Hello, world!");
    $ncx = $main->Width - $main->ScaleWidth;
    $ncy = $main->Height - $main->ScaleHeight;
    $main->Height($main->Label1->Height()+$ncy);
    $main->Width($main->Label1->Width()+$ncx);
    $main->Show();
    Win32::GUI::Dialog();
    sub Main_Terminate { -1; }

where $ncx and $ncy are the non-client area width and height ;-)

__END__
# Aldo Calpini
print sort {$_{$a} cmp $_{$b}} values %{{split undef, 
"xritajbugne fahokem csuctawer jhdtlrnpqloevkshpr"}};




Reply via email to