BELOW CODE MIGHT BE USED TO SIMULATE LISTVIEW CHECKBOXES BY TOGGLING  DISPLAYED 
IMAGES IN AN IMAGE LIST.  YOU CAN SUBSTITUTE THE Bitmap filenames TO THOSE YOU 
HAVE ON HAND. 

use Win32::GUI;

$W = new Win32::GUI::DialogBox(
    -name => "Window",
    -text => "ListView Checkboxes Workaround",
    -width => 275,
    -height => 250,
    -left => 50,
    -top => 50
);


$B1 = new Win32::GUI::Bitmap("node.bmp");
$B2 = new Win32::GUI::Bitmap("node_sel.bmp");
$IL = new Win32::GUI::ImageList(16, 16, 0, 2, 10);
$IL->Add($B1, 0);
$IL->Add($B2, 0);

$LV = $W->AddListView(
         -name => "ListView",
         -multisel => 0,
         -left => 12,
         -top => 10,
         -height => 200,
         -width  => 225, 
);
$LV->View(1);  # detailed listing, i.e. columns and rows
$LV->SetImageList($IL,1);

$W->Show();
$W->BringWindowToTop();
Load_ListView();


Win32::GUI::Dialog();


sub Load_ListView {
   $LV->InsertColumn(-index => 1, -width => 200, -text => "FRUIT");  
   
   $LV->InsertItem(-item => 0, -text => "Apples",  -image => 0);
   $LV->InsertItem(-item => 1, -text => "Pears",   -image => 1);
   $LV->InsertItem(-item => 2, -text => "Oranges", -image => 0);
}  

sub ListView_ItemClick {
   $item=shift;
   %data=();
   %data=$LV->ItemInfo($item);  
   if ($data{-image} == 0) {
      $LV->ChangeItem(-item => $item, -image => 1);   
   } else {
      $LV->ChangeItem(-item => $item, -image => 0);    
   }

}

sub Window_Terminate {
   return -1;
}



Reply via email to