I have Further Investigated the problem and it seems the underlying problem is something in SendMessage from the API?
I tried to write my own routine to retrieve the information I want. I get precisely the same results as with the WIN32::GUI Module, that is: Retrieving the item count works but attempting to retrieve the item text results in GPF in recieving App.
Any Windows API C gurus out there that can point me in the right direction? Am I passing a bad parameter? I want to retrieve the displayed text of the first item of the first row in the first column. ( Not the headers )
Snippet requires Win32::API
sub ListView_GetItem ( $$ ) { # ( $wh_Handle, $RowIndex )
#constants
use constant LVIF_TEXT => 0x01;
use constant LVM_GETITEMCOUNT => 0x1004;
use constant LVM_GETITEM => 0x1005; #LVM_FIRST +5
#types
typedef Win32::API::Struct _LV_ITEM => qw(
UINT mask;
int iItem;
int iSubItem;
UINT state;
UINT stateMask;
LPTSTR pszText;
int cchTextMax;
int iImage;
LPARAM lParam;
);
#Vars
my $handle = shift;
my $index = 0;
my %Item = {}; #Hash to hold Item info
my $LV_Item = Win32::API::Struct->new ( '_LV_ITEM');
$Lv_Item->{mask} = LVIF_TEXT;
$Lv_Item->{iItem} = 0;
$Lv_Item->{iSubItem} = 1;
#LRESULT SendMessage(
#
# HWND hWnd, // handle of destination window
# UINT Msg, // message to send
# WPARAM wParam, // first message parameter
# LPARAM lParam // second message parameter
# );
#LVM_GETITEM
#wParam = 0;
#lParam = (LPARAM) (LV_ITEM FAR*) pitem;
Win32::API->Import(
'USER32', 'LRESULT SendMessage( HWND hWnd, UINT Msg, WPARAM wP
+aram, LPARAM lParam)'
) || die "fAILED TO IMPORT sENDmESSAGE\n";
#works Fine
$items = SendMessage ($handle,LVM_GETITEMCOUNT,0,0);
print "Sendmessage saw $items items\n";
#Causes GPF in Recipient
SendMessage ($handle,LVM_GETITEM,0,$Lv_Item) || die "Message Faile
+d $!\n";
$text = chop $Lv_Item->{pszText};
print "The text is $text \n!";
return $text;
}