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

    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?

    :)

    How did you hear about "LVM_SETITEMCOUNT" (what docs are you reading)? Why do you think you have to hook it?

    There is no example on the internet anywhere of a virtual Win32::GUI::ListView ... Win32::GUI is a dead end, hasn't been updated in forever, doesn't support unicode.... other problems with Win32::GUI and why I laught at those choosing Win32::GUI

        Good, thats the site, i could only find one partial example there, it hints that you need to hook a diff. messages, the ones about getting items. Im AFK ATM