use warnings; use strict; no strict 'subs'; my @list_items; use constant LVM_SETITEMCOUNT => 4143; use Win32::GUI::Constants qw(/^(MB_|ILC_|IDYES|SB_|DT_|WS_|LVS_)/); use Win32::GUI(); my $wnd = Win32::GUI::Window->new( -size => [500, 500] ); my $lines = $wnd->AddTextfield( -prompt => ['Lines:', 80], -pos => [160, $wnd->ScaleHeight - 30], -height => 24, -width => 100, -popstyle => WS_BORDER, -tabstop => 1, -text => 5000 ); my $refresh_btn = $wnd->AddButton( -pos => [10, $wnd->ScaleHeight - 30], -size => [100, 24], -text => 'Refresh', -onClick => \&update_list ); my $list = $wnd->AddListView( -name => 'list', -pos => [10, 10], -size => [$wnd->ScaleWidth - 20, $wnd->ScaleHeight - 50], -gridlines => 1, -popstyle => WS_BORDER, -pushstyle => LVS_OWNERDATA ); $list->Hook(LVM_SETITEMCOUNT, sub { ################ # What I need to write there? ################ }); $list->InsertColumn( -width => 24 ); $list->InsertColumn( -width => 200 ); $wnd->Center(); $wnd->Show(); Win32::GUI::Dialog; sub update_list() { my $line = 0; my $max_lines = $lines->Text(); $list->Clear(); @list_items = (); for (1 .. $max_lines) { push(@list_items, {-text => [$_, rand(9999999)]}); } $list->SetItemCountEx(scalar @list_items, 0); }