Hi everyone,

I'm trying to add ListView group. Like this : http://www.codeproject.com/KB/list/GroupListView/GroupListView.jpg But does't to work.!

Here is my perl Win32::GUI code;

Edit// This is my new code, but does not work.!
OS : Win 7
Perl : 5.10
Win32::GUI 1.06

use strict; use warnings; use Win32::GUI qw( WS_VISIBLE WS_CHILD WS_EX_CLIENTEDGE); sub LVS_REPORT() {0x0001}; sub LVM_FIRST() {4096}; sub LVM_ENABLEGROUPVIEW() {LVM_FIRST + 157}; sub LVM_INSERTCOLUMN() {LVM_FIRST + 27}; sub LVM_INSERTITEM() {LVM_FIRST + 7}; sub LVM_INSERTGROUP() {LVM_FIRST + 145}; sub LVGS_NORMAL() { 0 }; sub LVGA_FOOTER_CENTER() { 16 }; my $Win = new Win32::GUI::Window( -width => 330, -height => 269, -name => "Win", -text => "listview group test" ); my $datalistview = $Win->AddListView( -text => "", -name => "ListView_1", -left => 7, -top => 17, -width => 300, -height => 141, -style => WS_VISIBLE | WS_CHILD | LVS_REPORT, # LVS_REPORT for +the report style -exstyle => WS_EX_CLIENTEDGE ); #-----------------------# # Inserting Column1 # MSDN create and inset column api # msdn url : http://msdn.microsoft.com/en-us/library/bb774743(v=VS.85) +.aspx # UINT mask; # int fmt; # int cx; # LPTSTR pszText; # int cchTextMax; # int iSubItem; # int iImage; # int iOrder; # int cxMin; # int cxDefault; # int cxIdeal; my $paskl = pack('IIIPIIIIIII', 1|23|8|4|2, # LVCF_FMT | LVCF_ORDER | LVCF_SUBITEM | LVCF_TEXT | LVCF_ +WIDTH 0, # LVCFMT_LEFT 110, # Column Width "Column1", # Column Text 1024, # Column Text buffer 0, # SubItem 0, # Image 0, # Order 0, # avaible in vista; not used 0, # avaible in vista; not used 0 # avaible in vista; not used );# "Column1",0,-0- this is index my $returnvalue1 = $datalistview->SendMessage(LVM_INSERTCOLUMN,0,$pask +l); print "Column1 index = $returnvalue1\n"; # Inserting Column2 my $pask2 = pack('IIIPIIIIIII', 1|23|8|4|2, # LVCF_FMT | LVCF_ORDER | LVCF_SUBITEM | LVCF_TEXT | LVCF_ +WIDTH 0, # LVCFMT_LEFT 110, # Column Width "Column2", # Column Text 1024, # Column Text buffer 1, # SubItem 0, # Image 0, # Order 0, # avaible in vista; not used 0, # avaible in vista; not used 0 # avaible in vista; not used );# "Column1",0,-0- this is index my $returnvalue2 = $datalistview->SendMessage(LVM_INSERTCOLUMN,1,$pask +2); print "Column2 index = $returnvalue2\n"; #-----------------------# #-----------------------# # Inserting items to ListView # typedef struct { # UINT mask; # int iItem; # int iSubItem; # UINT state; # UINT stateMask; # LPTSTR pszText; # int cchTextMax; # int iImage; # LPARAM lParam; # if (_WIN32_IE >= 0x0300) # int iIndent; # endif # if (_WIN32_WINNT >= 0x0501) # int iGroupId; # UINT cColumns; # UINT puColumns; # endif # if (_WIN32_WINNT >= 0x0600) # int piColFmt; # int iGroup; # endif # } LVITEM, *LPLVITEM; my $paskl3 = pack('IIIIIPIIIIIIIII', 1|16|512, # LVIF_TEXT | LVIF_INDENT | LVIF_COLUMNS 0, # item index 0, # subitem index 0, # state index 0, # statemask index "Item1", # item text 5, # item text buffer 0, # image 0, # param 0, # indent 0, # group id is 0 0, # ccolumns 0, # pucolumns 0, # group id is 0 0 # igroup ); my $institem1 = $datalistview->SendMessage(LVM_INSERTITEM,0,$paskl3); print "Item1 index = $institem1\n"; my $paskl4 = pack('IIIIIPIIIIIIIII', 1|16|512, # LVIF_TEXT | LVIF_INDENT | LVIF_COLUMNS 1, # item index 0, # subitem index 0, # state index 0, # statemask index "Item2", # item text 5, # item text buffer 0, # image 0, # param 0, # indent 1, # group id is 0 0, # ccolumns 0, # pucolumns 0, # group id is 0 0 # igroup # 1|16|512,0,0,0,0,"Item1",5,0,0,0,0,0,0,0,0 ); my $institem2 = $datalistview->SendMessage(LVM_INSERTITEM,1,$paskl4); print "Item2 index = $institem2\n"; #-----------------------# #-----------------------# # Sending message to listview and enabling group # msdn url : http://msdn.microsoft.com/en-us/library/aa931484.aspx # (HWND) hWndControl, # (UINT) LVM_ENABLEGROUPVIEW, # (WPARAM) wParam, // = (WPARAM) (BOOL) fEnable; # (LPARAM) lParam // = (LPARAM) (LPARAM) lParam; $datalistview->SendMessage(LVM_ENABLEGROUPVIEW,1,0); #-----------------------# #-----------------------# # msdn url : http://msdn.microsoft.com/en-us/library/aa453426.aspx # creating listview group # typedef struct LVGROUP { # UINT cbSize; # UINT mask; # LPWSTR pszHeader; # int cchHeader; # LPWSTR pszFooter; # int cchFooter; # int iGroupId; # UINT stateMask; # UINT state; # UINT uAlign; # } LVGROUP, *PLVGROUP; my $textg = "Group Test"; my $pasklaa = pack('IIPIIIIIII', 40, # cbSize 1|16|4, # LVGF_HEADER | LVGF_GROUPID | LVGF_STATE $textg, # adding group text pszHeader length($textg), # char size of text 0, # pszFooter 0, # cchFooter 0, # GroupId 0, # statemask LVGS_NORMAL, # state LVGA_FOOTER_CENTER # Alinga ); my $insetgroup = $datalistview->SendMessage(LVM_INSERTGROUP,-1,$paskla +a); print "insgroup1 - $insetgroup\n"; #-----------------------# $Win->Center(); $Win->Show(); Win32::GUI::Dialog(); __END__

Where is the my wrong?
Regards,
Ahmet.
Edit; 5 min later :) OK working now.

use strict; use warnings; use Win32::GUI qw( WS_VISIBLE WS_CHILD); sub LVS_REPORT() {0x0001}; sub LVM_FIRST() {4096}; sub LVM_ENABLEGROUPVIEW() {LVM_FIRST + 157}; sub LVM_INSERTCOLUMN() {LVM_FIRST + 27}; sub LVM_INSERTITEM() {LVM_FIRST + 7}; sub LVM_INSERTGROUP() {LVM_FIRST + 145}; sub LVGS_NORMAL() { 0 }; sub LVGA_FOOTER_CENTER() { 16 }; sub LVIF_GROUPID() { 256 }; sub LVM_SETITEM() {LVM_FIRST + 6 }; my $Win = new Win32::GUI::Window( -width => 330, -height => 269, -name => "Win", -text => "listview group test" ); my $datalistview = $Win->AddListView( -text => "", -name => "ListView_1", -left => 7, -top => 17, -width => 300, -height => 141, -checkbox => 1, -style => WS_VISIBLE | WS_CHILD | LVS_REPORT, # LVS_REPORT for +the report style ); #-----------------------# # Inserting Column1 # MSDN create and inset column api # msdn url : http://msdn.microsoft.com/en-us/library/bb774743(v=VS.85) +.aspx # UINT mask; # int fmt; # int cx; # LPTSTR pszText; # int cchTextMax; # int iSubItem; # int iImage; # int iOrder; # int cxMin; # int cxDefault; # int cxIdeal; my $paskl = pack('IIIPIIIIIII', 1|23|8|4|2, # LVCF_FMT | LVCF_ORDER | LVCF_SUBITEM | LVCF_TEXT | LVCF_ +WIDTH 0, # LVCFMT_LEFT 110, # Column Width "Column1", # Column Text 1024, # Column Text buffer 0, # SubItem 0, # Image 0, # Order 0, # avaible in vista; not used 0, # avaible in vista; not used 0 # avaible in vista; not used );# "Column1",0,-0- this is index my $returnvalue1 = $datalistview->SendMessage(LVM_INSERTCOLUMN,0,$pask +l); print "Column1 index = $returnvalue1\n"; # Inserting Column2 my $pask2 = pack('IIIPIIIIIII', 1|23|8|4|2, # LVCF_FMT | LVCF_ORDER | LVCF_SUBITEM | LVCF_TEXT | LVCF_ +WIDTH 0, # LVCFMT_LEFT 110, # Column Width "Column2", # Column Text 1024, # Column Text buffer 1, # SubItem 0, # Image 0, # Order 0, # avaible in vista; not used 0, # avaible in vista; not used 0 # avaible in vista; not used );# "Column1",0,-0- this is index my $returnvalue2 = $datalistview->SendMessage(LVM_INSERTCOLUMN,1,$pask +2); print "Column2 index = $returnvalue2\n"; #-----------------------# #-----------------------# # Inserting items to ListView # typedef struct { # UINT mask; # int iItem; # int iSubItem; # UINT state; # UINT stateMask; # LPTSTR pszText; # int cchTextMax; # int iImage; # LPARAM lParam; # if (_WIN32_IE >= 0x0300) # int iIndent; # endif # if (_WIN32_WINNT >= 0x0501) # int iGroupId; # UINT cColumns; # UINT puColumns; # endif # if (_WIN32_WINNT >= 0x0600) # int piColFmt; # int iGroup; # endif # } LVITEM, *LPLVITEM; my $paskl3 = pack('IIIIIPIIIIIIIII', 1|16|512, # LVIF_TEXT | LVIF_INDENT | LVIF_COLUMNS 0, # item index 0, # subitem index 0, # state index 0, # statemask index "Item1", # item text 5, # item text buffer 0, # image 0, # param 0, # indent 0, # group id is 0 0, # ccolumns 0, # pucolumns 0, # group id is 0 0 # igroup ); my $institem1 = $datalistview->SendMessage(LVM_INSERTITEM,0,$paskl3); print "Item1 index = $institem1\n"; my $paskl4 = pack('IIIIIPIIIIIIIII', 1|16|512, # LVIF_TEXT | LVIF_INDENT | LVIF_COLUMNS 1, # item index 0, # subitem index 0, # state index 0, # statemask index "Item2", # item text 5, # item text buffer 0, # image 0, # param 0, # indent 1, # group id is 0 0, # ccolumns 0, # pucolumns 0, # group id is 0 0 # igroup # 1|16|512,0,0,0,0,"Item1",5,0,0,0,0,0,0,0,0 ); my $institem2 = $datalistview->SendMessage(LVM_INSERTITEM,1,$paskl4); print "Item2 index = $institem2\n"; #-----------------------# #-----------------------# # Sending message to listview and enabling group # msdn url : http://msdn.microsoft.com/en-us/library/aa931484.aspx # (HWND) hWndControl, # (UINT) LVM_ENABLEGROUPVIEW, # (WPARAM) wParam, // = (WPARAM) (BOOL) fEnable; # (LPARAM) lParam // = (LPARAM) (LPARAM) lParam; $datalistview->SendMessage(LVM_ENABLEGROUPVIEW,1,0); #-----------------------# #-----------------------# # msdn url : http://msdn.microsoft.com/en-us/library/aa453426.aspx # creating listview group # typedef struct LVGROUP { # UINT cbSize; # UINT mask; # LPWSTR pszHeader; # int cchHeader; # LPWSTR pszFooter; # int cchFooter; # int iGroupId; # UINT stateMask; # UINT state; # UINT uAlign; # } LVGROUP, *PLVGROUP; my $textg = "Group Test"; my $pasklaa = pack('IIPIIIIIII', 40, # cbSize 16|1|4, # LVGF_HEADER | LVGF_GROUPID | LVGF_STATE $textg, # adding group text pszHeader length($textg), # char size of text 0, # pszFooter 0, # cchFooter 0, # GroupId 0, # statemask LVGS_NORMAL, # state LVGA_FOOTER_CENTER # Alinga ); my $insetgroup = $datalistview->SendMessage(LVM_INSERTGROUP,-1,$paskla +a); print "insgroup1 - $insetgroup\n"; #-----------------------# # typedef struct _LVITEM { # typedef struct _LVITEM { # UINT mask; # int iItem; # int iSubItem; # UINT state; # UINT stateMask; # LPTSTR pszText; # int cchTextMax; # int iImage; # LPARAM lParam; # if (_WIN32_IE >= 0x0300) # int iIndent; # endif # int iGroupId; # } LVITEM; my $pasklaaas = pack('IIIIIIIIIII', LVIF_GROUPID, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ); my $insetgroupas = $datalistview->SendMessage(LVM_SETITEM,0,$pasklaaas +); print "setgroup1 - $insetgroupas\n"; $Win->Center(); $Win->Show(); Win32::GUI::Dialog();

In reply to Win32 GUI - How to add Group to ListView? by Ahmet

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.