artem78 has asked for the wisdom of the Perl Monks concerning the following question:
Hello. I need an example, how create virtual listview with Win32::GUI. I want to know, how to use LVM_SETITEMCOUNT hook and where in code I need to add items in ListView?
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); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Win32::GUI::ListView in virtual mode
by Anonymous Monk on May 03, 2016 at 23:12 UTC | |
by artem78 (Novice) on May 04, 2016 at 12:01 UTC | |
by Anonymous Monk on May 04, 2016 at 12:17 UTC | |
by Anonymous Monk on May 06, 2016 at 01:11 UTC | |
by Anonymous Monk on May 06, 2016 at 01:10 UTC |