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

Re: Select an item in a list box.

Expand Messages
  • brentje
    Hey, thanks for the reply, even though I managed to muddle through it myself eventually. I m slowly getting my head around the SendMessage function. Now I m
    Message 1 of 4 , Jan 17, 2006
    • 0 Attachment
      Hey, thanks for the reply, even though I managed to muddle through it
      myself eventually. I'm slowly getting my head around the SendMessage
      function. Now I'm onto a different task that will probably involve
      SendMessage. I'm trying to read the records in a datagrid. Datagrids
      are tricky, since they are pure .Net controls and not standard Windows
      controls like Listbox and Combobox. They don't seem to have any
      messages associated with them on MSDN. Short of writing an extension
      to the datagrid class, are there any ways to interact with a datagrid?
      Any help would be appreciated.

      Thanks
      Brent

      --- In perlguitest@yahoogroups.com, "Piotr Kaluski" <pkaluski@p...> wrote:
      >
      > ListBox is a standard control so you don't have to bother with Virtual
      > Memory functions.
      > Last parameter of SendMessage should be a pointer to a string, which
      > is not a straightforward thing.
      >
      > Try this:
      > my $value = "Value";
      >
      > my $ptr = pack( 'P', $value );
      >
      > SendMessage( $H_ListBox, 0x018C , -1, unpack( 'L!', $ptr ) );
      >
      > Have a look at perlpacktut manual page.
      >
      > Note: I didn't try the code above.
      >
      > --Piotr
      >
      > --- In perlguitest@yahoogroups.com, "brentje" <brentje@y...> wrote:
      > >
      > > I'm going crazy. I can't look at this code anymore. Could someone
      > > please tell me what I'm doing wrong with this SendMessage statement.
      > >
      > > For clarification, 0x018C is the hex code for the LB_SELECTSTRING
      > message.
      > >
      > >
      > >
      > > my $FieldValue = "An Item\0";
      > >
      > > my $lvitem = AllocateVirtualBuffer( $H_ListBox,
      length($s_FieldValue) );
      > >
      > > WriteToVirtualBuffer( $lvitem, $FieldValue );
      > > SendMessage( $H_ListBox, 0x018C , -1, $lvitem->{ 'ptr' } );
      > >
      > > Result comes back with 0. Which isn't right since the item's index is
      > > actually 3, but isn't an error code either. It doesn't select
      anything.
      > >
      > >
      > > Here's the link to the MSDN description of LB_SELECTSTRING.
      > >
      >
      http://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/commctls/listboxes/listboxreference/listboxmessages/LB_SELECTSTRING.asp
      > >
      > > Any help would be appreciated, since I have to work with a lot of
      > > listboxes.
      > >
      > > Thanks
      > > Brent
      > >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.