Loading ...
Sorry, an error occurred while loading the content.

Re: Finding rectangle of selected ListBox item

Expand Messages
  • Tim Mitchell
    OK, I got it, thanks to Brentje s post #1273. The key seems to be defining $ptr with: $ptr = pack( LLLL , 0,0,0,0); and then packing it again with: pack( P ,
    Message 1 of 2 , Jun 6, 2006
    • 0 Attachment
      OK, I got it, thanks to Brentje's post #1273.
      The key seems to be defining $ptr with:

      $ptr = pack( "LLLL", 0,0,0,0);

      and then packing it again with:

      pack('P', $ptr);

      Here is what I came up with: (not to mention the typo)

      # Use LB_GETITEMRECT 0xF198 to get the rectangle coordinates of
      the listbox item
      $ptr = pack( "LLLL", 0,0,0,0);
      my $result = SendMessage($Listbox[0], 0x0198, $Index, unpack('L L
      L L', pack('P', $ptr)));
      my @coords = unpack('L L L L', $ptr);
      print("result = $result\n");
      print("left = $coords[0]\n");
      print("right = $coords[1]\n");
      print("top = $coords[2]\n");
      print("bottom = $coords[3]\n");

      --- In perlguitest@yahoogroups.com, "Tim Mitchell" <maxquig@...>
      wrote:
      >
      > Hello,
      >
      > I'm having trouble using SendMessage to get the rectangle
      > coordinates of an item using LB_GETITEMRECT.
      >
      > my $member = "ABC";
      > # Use LB_FINDSTRINGEXACT (0xF1A2) to find the index of the member
      > my $ptr = pack( 'P', $member );
      > my $Index = SendMessage( $Listbox[0], 0x01A2 , 0, unpack( 'L!',
      > $ptr ) );
      > print("$member Index = $Index\n");
      > # Use LB_GETITEMRECT (0xF198) to get the rectangle coordinates
      of
      > the listbox item
      > $ptr = pack( 'P', $Index );
      > my $result = SendMessage( $Listbox[0], 0x0198 , 1, unpack( 'L!',
      > $ptr ) );
      > print("result = $result\n");
      > print("ltrb = ", unpack( 'L!', $ptr ));
      >
      > This code fragment finds the correct index of my item. Then
      > SendMessage returns a result of 1, indicating it found the
      > coordinates, but the last print line does not return 4 unpacked
      > coordinates, just one apparently random value:
      > ltrb = 47425828
      >
      > I've tried things like:
      > @coords = unpack( 'L!', $ptr );
      > $coords[0] gets the random value. $coords[1] ... etc get nothing.
      >
      > I'd appreciate any help on this one.
      >
      > Tim
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.