To get which items have the box checked you use the method
"ItemCheck(INDEX)" method.
I took your code and added a button to query this.
The button looks like this:
#----------
my $fab1 = $Window->AddButton
#----------
(
-name => "GetChecks",
-left => 120,
-top => 200,
-text => " Get Checks ",
-visible => 1,
-default => 1,
-ok => 1,
# -cancel => 1,
-tabstop => 1,
);
then I added an event to execute when the button is pushed:
sub GetChecks_Click
{
#
# this gets the number of items in the ListView
#
my $cnt = $Window->ListView->Count();
#
# a listview index starts at zero so
#
foreach ( 0 .. ( $cnt - 1 ) )
{
$del[ $_ ] = $Window->ListView->ItemCheck( $_ );
}
#
# @del is an array that contains a 1 if the box is checked
# and a zero if the box is not checked
#
print "Count = $cnt\n";
print "Checked Items = @del \n";
}
I changed the directory to one of my own ... it has three files in it.
I checked the first one and clicked on my button
Count = 3
Checked Items = 1 0 0
was printed in the dos box.
I checked the other two and
Count = 3
Checked Items = 1 1 1
was printed in the dos box.
The code is not beautiful, but it seems to work.
I would recommend downloading the source code from Source Forge as it
contains the docs,
which are incomplete but the best we have.
You can also find the docs at http://dada.perl.it/gui_docs/gui.html
HTH
Jeff Colwell
Senior Software Engineer
Equity Residential Properties Trust
Phone: 312-928-1146 Fax: 312-526-0999 Cell: 312-656-5962
No electrons were harmed in making this e-mail message.
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Wednesday, August 29, 2001 1:20 PM
To: [email protected]
Subject: [perl-win32-gui-users] How to get items that are checked in a
list view.
Hello,
I do get items in a list view that are checked to put in an array/hash/what
ever. My code list the contents of a directory and puts them in a list
view what I want is that after someone selects the files they want by
checking the box next to it. They click on a button and it copies the
selected file to a new location. Any ideas?
Thanks,
Joe
Here is my code:
use Win32::GUI;
$Window = new GUI::Window(
-name => "Window",
-text => "WEB Deploy v1.0.0",
-width => 800,
-height => 400,
-left => 100,
-top => 100,
);
$Window->AddListView(
-name => "ListView",
-text => "hello world!",
-left => 10,
-top => 10,
-width => 780,
-height => 180,
-style => WS_CHILD | WS_VISIBLE | 1,
-fullrowselect => 1,
-gridlines => 1,
-checkboxes => 1,
# -hottrack => 1,
);
$width = $Window->ListView->ScaleWidth;
$Window->ListView->InsertColumn(
-index => 0,
-width => $width/4,
-text => "File",
);
$Window->ListView->InsertColumn(
-index => 1,
-subitem => 1,
-width => $width/1.33,
-text => "Path",
);
sub InsertListItem {
my($name, $description) = @_;
my $item = $Window->ListView->InsertItem(
-item => $Window->ListView->Count(),
-text => $name,
# -index => $Window->ListView->Count(),
);
$Window->ListView->SetItem(
-item => $item,
-subitem => 1,
-text => $description,
);
}
$whereami = `chdir`;
chomp($whereami);
$dir = "L:\\Inetpub\\Timesheet";
push @dir,$dir;
chomp($dir);
while ($dirs=pop @dir){
chomp($dirs);
chdir $dirs;
while (<*>) {
next if ($_ eq ".");
next if ($_ eq "..");
if (-d $_) {
next if (-l $_);
print "\t Dir-> ",$_,"\n" if $DEBUG;
push @dir,$dirs."/".$_;
} else {
InsertListItem($_, $dirs);
print "\t File-> ",$_," => $size\n" if $DEBUG;
}
}
exit if $DEBUG;
chdir $whereami;
}
# $Window->ListView->TextColor(hex("0000FF"));
$Window->Show();
$Window->Dialog();
_______________________________________________
Perl-Win32-GUI-Users mailing list
[email protected]
http://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users