use strict; use warnings; use Cwd; use Win32::GUI qw(WS_VSCROLL WS_VISIBLE); use Win32::OLE; use Win32::GUI::AxWindow; my $dir = getcwd; our $OLEControl; # main Window my $Window = new Win32::GUI::Window ( -title => "Win32::GUI::AxWindow and Win32::OLE", -pos => [0, 0], -size => [620, 470], -name => "Window", ) or die "new Window"; # Create AxWindow our $Control = new Win32::GUI::AxWindow ( -parent => $Window, -name => "Control", -pos => [150, 0], -size => [400, 400], -control => "Shell.Explorer.2", ) or die "new Control"; my $PicList = $Window->AddListbox( -name => "PicList", -top => 0, -left => 0, -width => 125, -height => 110, -addstyle => WS_VISIBLE | 3 | WS_VSCROLL, ); #the button are for test only $Window->AddButton( -name => "display", -align => "left", -text => "Display", -left => 0, -top => 200, -width => 100, -height => 50, ); opendir DH, $dir or die "Cannot open $dir: $!"; my @files = grep { ! -d } readdir DH; closedir DH; #choose only jpg or gif files my @picFiles = grep /.+\.jpg|gif/,@files; # work with @files foreach my $item (@picFiles) { $PicList->Add($item); } #the following button just for test only sub display_Click { $OLEControl = $Control->GetOLE(); $OLEControl->Navigate("about:Blank"); # Clear control } #Show application window $Window->Show(); #Enter event loop Win32::GUI::Dialog(); #Hide windows on exit $Window->Hide(); undef $Window; exit(0); sub PicList_Click { my $ListSelection = $PicList->SelectedItem(); my $selectedPic = $PicList->GetString($ListSelection); my $picture = $dir . '/' . $selectedPic; # Get Ole object $OLEControl = $Control->GetOLE(); $OLEControl->Navigate("about:Blank"); # Clear control my $pic = "