Quickly guessing (I don't have an environment to test this at the moment):

This code:

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
);

may not do what you think, as I don't think the pack() will increment
the reference count of the "item1" string, and so I think it will
immediately go out of scope after the pack command leaving the
structure pointing to potentially random string data.

Try this instead:

my $item1 = "item1";
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
);

I think the listbox makes a copy of the text - so that should be sufficient.

Let us know how you get on.

Regards,
Rob.


On 27 March 2011 14:44, FPerl <tarak...@hotmail.com> wrote:
>
> Hi,
>
> I'm testing ListView Groups on my Windows 7 os.This code working perfect but
> text values displaying in Chinese charset.
> I writing value in latin char but this app displaying Unicode char.I not
> understand.
> Where is the wrong? Thank you.
> ( Perl v5.10 Win32::GUI v1.06 ).
>
> Image :
> http://old.nabble.com/file/p31250335/2c7119b6.png
>
> Installed language packs;English, Turkish
>
> 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 LVIF_GROUPID() { 256 };
> sub LVM_SETITEM() {LVM_FIRST + 76 };
> sub LVGF_HEADER() {1};
> sub LVGF_FOOTER() {2};
> sub LVGF_GROUPID() {16};
> sub LVGF_ALIGN() {8};
> sub LVGF_STATE() {4};
> sub LVGA_FOOTER_LEFT() {8};
> sub LVGS_COLLAPSIBLE() {0x00000008};
>
> my $Win = new Win32::GUI::Window(
>      -width  => 330,
>      -height => 269,
>      -name   => "Win",
>      -text   => "listview group test",
>          -onResize => \&win_size,
>      );
>
> my $datalistview = $Win->AddListView(
>       -text    => "",
>       -name    => "ListView_1",
>           -checkboxes => 1,
>           -style => WS_VISIBLE | WS_CHILD | LVS_REPORT , # LVS_REPORT for the
> report style
>      );
> #-------------------------------------------------------------------------------------------------------------------#
> # 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;
> # Inserting Column1
> 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,$paskl);
> 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,$pask2);
> 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
> );
> 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
>  # UINT   cbSize;
>  # UINT   mask;
>  # LPWSTR pszHeader;
>  # int    cchHeader;
>  # LPWSTR pszFooter;
>  # int    cchFooter;
>  # int    iGroupId;
>  # UINT   stateMask;
>  # UINT   state;
>  # UINT   uAlign;
> # if _WIN32_WINNT >= 0x0600
>  # LPWSTR pszSubtitle;
>  # UINT   cchSubtitle;
>  # LPWSTR pszTask;
>  # UINT   cchTask;
>  # LPWSTR pszDescriptionTop;
>  # UINT   cchDescriptionTop;
>  # LPWSTR pszDescriptionBottom;
>  # UINT   cchDescriptionBottom;
>  # int    iTitleImage;
>  # int    iExtendedImage;
>  # int    iFirstItem;
>  # UINT   cItems;
>  # LPWSTR pszSubsetTitle;
>  # UINT   cchSubsetTitle;
> my $pasklaav = pack('IIPIIIIIIIIIIIIIIIIIIIII',
> 1024,                                   # cbSize
> LVGF_HEADER|LVGF_GROUPID|LVGF_ALIGN|LVGF_STATE,
> "test1",                        # adding group text pszHeader
> 256,                            # char size of text
> 0,                                      # pszFooter
> 0,                                      # cchFooter
> 0,                                      # GroupId
> 0,                                      # statemask
> LVGS_COLLAPSIBLE,       # state
> LVGA_FOOTER_LEFT,       # Aling
> 0,                                      # pszSubtitle
> 0,                                      # cchSubtitle
> 0,                                      # pszTask
> 0,                                      # cchTask
> 0,                                      # pszDescriptionTop
> 0,                                      # cchDescriptionTop
> 0,                                  # pszDescriptionBottom
> 0,                                      # cchDescriptionBottom
> 0,                                      # iTitleImage
> 0,                                      # iExtendedImage
> 0,                                      # iFirstItem
> 0,                                      # cItems
> 0,                                      # pszSubsetTitle
> 0                                       # cchSubsetTitle
> );
> # inserting the group to listview
> my $insetgroupv = $datalistview->SendMessage(LVM_INSERTGROUP,-1,$pasklaav);
> print "insgroup1 - $insetgroupv\n";
>
>
> my $pasklaavt = pack('IIPIIIIIIIIIIIIIIIIIIIII',
> 1024,                                   # cbSize
> LVGF_HEADER|LVGF_GROUPID|LVGF_ALIGN|LVGF_STATE,
> "test1",                        # adding group text pszHeader
> 256,                            # char size of text
> 0,                                      # pszFooter
> 0,                                      # cchFooter
> 1,                                      # GroupId
> 0,                                      # statemask
> LVGS_COLLAPSIBLE,       # state
> LVGA_FOOTER_LEFT,       # Aling
> 0,                                      # pszSubtitle
> 0,                                      # cchSubtitle
> 0,                                      # pszTask
> 0,                                      # cchTask
> 0,                                      # pszDescriptionTop
> 0,                                      # cchDescriptionTop
> 0,                                  # pszDescriptionBottom
> 0,                                      # cchDescriptionBottom
> 0,                                      # iTitleImage
> 0,                                      # iExtendedImage
> 0,                                      # iFirstItem
> 0,                                      # cItems
> 0,                                      # pszSubsetTitle
> 0                                       # cchSubsetTitle
> );
> # inserting the group to listview
> my $insetgroupvt =
> $datalistview->SendMessage(LVM_INSERTGROUP,-1,$pasklaavt);
> print "insgroup2 - $insetgroupvt\n";
> #-------------------------------------------------------------------------------------------------------------------#
> # http://msdn.microsoft.com/en-us/library/aa453430(MSDN.10).aspx
> # Seting item with listview group
> # 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,   # mask
> 0,                              # item index
> 0,                              # subitem
> 0,                              # state
> 0,                              # statemask
> 0,                              # pszText
> 0,                              # Text buffer
> 0,                              # image index
> 0,                              # lParam
> 0,                              # iIndent
> 0,                              # groupid
> );
> my $insetgroupas = $datalistview->SendMessage(LVM_SETITEM,0,$pasklaaas);
> print "setgroup1 - $insetgroupas\n";
>
> my $pasklaaast = pack('IIIIIIIIIII',
> LVIF_GROUPID,   # mask
> 1,                              # item index
> 0,                              # subitem
> 0,                              # state
> 0,                              # statemask
> 0,                              # pszText
> 0,                              # Text buffer
> 0,                              # image index
> 0,                              # lParam
> 0,                              # iIndent
> 1,                              # groupid
> );
> my $insetgroupast = $datalistview->SendMessage(LVM_SETITEM,0,$pasklaaast);
> print "setgroup2 - $insetgroupast\n";
>
> #-------------------------------------------------------------------------------------------------------------------#
> $Win->Center();
> $Win->Show();
> Win32::GUI::Dialog();
>
> sub win_size {
>  my ($self) = @_;
>  my ($width, $height) = ($self->GetClientRect())[2..3];
>  $self->ListView_1->Resize($width+1, $height+1) if exists
> $self->{ListView_1};
> }
>
> Regards...
> --
> View this message in context: 
> http://old.nabble.com/Win32%3A%3AGUI-ListBox-Group---Why-display-text-values-in-Chinese-charset--tp31250335p31250335.html
> Sent from the perl-win32-gui-users mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> Enable your software for Intel(R) Active Management Technology to meet the
> growing manageability and security demands of your customers. Businesses
> are taking advantage of Intel(R) vPro (TM) technology - will your software
> be a part of the solution? Download the Intel(R) Manageability Checker
> today! http://p.sf.net/sfu/intel-dev2devmar
> _______________________________________________
> Perl-Win32-GUI-Users mailing list
> Perl-Win32-GUI-Users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
> http://perl-win32-gui.sourceforge.net/
>

------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software 
be a part of the solution? Download the Intel(R) Manageability Checker 
today! http://p.sf.net/sfu/intel-dev2devmar
_______________________________________________
Perl-Win32-GUI-Users mailing list
Perl-Win32-GUI-Users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/perl-win32-gui-users
http://perl-win32-gui.sourceforge.net/

Reply via email to