in reply to adding multiple labels with win32::GUI

Update: For more information on dealing with Label positioning read below. After rereading your post, it sounds like you might be better off using a TextField, ListView, or Listbox control as BrowserUk suggested.

First, it should be Show instead of show, and second, you can drop it from the Label controls -- it's unnecessary.

This leaves you with the following:

use strict; use Win32::GUI; my $mw = Win32::GUI::Window->new ( -name => 'Main', -width => 300, -height => 100, -text => 'bbtrack', ); my $label1 = $mw->AddLabel( -text => "hello"); my $label2 = $mw->AddLabel( -text => "hello2"); $mw->Show(); Win32::GUI::Dialog();

What is going on is you are laying one Label directly on top of the other one so it looks as though only one is created. To verify this, change the text of the first Label to "hello world". Now, the overlay should be easy to see.

Try specifying the position of the second Label by using one or more of the following options: -left, -top, or -pos. Here are a few examples:

my $label2 = $mw->AddLabel( -text => "hello2", -left => 30);

or even:

my $label2 = $mw->AddLabel( -text => "hello2", -top => 15);

Of course, this can be problematic because of fonts so you could use the Height and Width methods:

my $label2 = $mw->AddLabel( -text => "hello2", -left => ($label1->Width + 2)); ## OR my $label2 = $mw->AddLabel( -text => "hello2", -top => ($label1->Height + 2));

You might also take a look at the GridLayout control. Here's one example:

use Win32::GUI; use Win32::GUI::GridLayout; my $mw = Win32::GUI::Window->new ( -name => 'Main', -width => 300, -height => 100, -text => 'bbtrack', ); my $grid = apply Win32::GUI::GridLayout($mw, 4, 4, 0, 0); for my $col (1 .. 4) { for my $row (1 .. 4) { my $lab = $mw->AddLabel( -name => "MainLabel$col$row", -text => "C: $col, R: $row"); $grid->add($lab, $col, $row); } } $grid->recalc; $mw->Show(); Win32::GUI::Dialog(); sub Main_Resize { $grid->recalc(); }
Rob