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

Re: A SysListView32 control with multiple columns

Expand Messages
  • Piotr Kaluski
    ... Dennis, I had a look at your code. I haven t tested it yet, but I have some comments and would like to hear your and other people s opinion. I have placed
    Message 1 of 13 , Nov 1, 2005
    • 0 Attachment
      --- In perlguitest@yahoogroups.com, "Piotr Kaluski" <pkaluski@p...> wrote:
      >
      > >
      > > If I was to do this, what would I do with the patch or should I try
      > to
      > > get set up for CVS access to SourceForge?
      >
      > The best way would be if you take the most recent files from CVS
      > (Instructions how to do it are here:
      > https://sourceforge.net/cvs/?group_id=104592) and apply your changes
      > there and than send me a patch. Note that after getting the files
      > from
      > CVS, you have to remove build.pl file (yes: REMOVE). Otherwise the
      > code
      > will not build.
      > Please send a patch directly to me. Yahoo eats some spaces when
      > displaying posts and "patch" program gets confused.
      > Eventualy, if you really can't make cvs work for you, you can modify
      > whatever file version you have and send it to me. Again - to me
      > directly. Or even better - post changes in the group and send it to
      > me
      > directly (so people will have an opportunity to comment).
      >
      > -Piotr
      >

      Dennis,
      I had a look at your code. I haven't tested it yet, but I have some
      comments and would like to hear your and other people's opinion.
      I have placed your code (and diffs with release 1.50.4) in the files
      section of this group (new_lv.zip file).
      Your code is terse, which proves that you have a pretty good command
      of perl. However, I am afraid that this terseness, may make the code
      slightly less readable for some less experienced developers.

      The main point of your change was to give a user a chance to choose
      not only an element from the list, but also a column in this element.
      So you had to add a mechinism to pass an index of a column (subitem).
      You have chosen, to merge this parameter with list view item index.
      The code looks as follows:

      #define pCW ((CWPSTRUCT*)lParam)
      LRESULT HookProc (int code, WPARAM wParam, LPARAM lParam)
      {
      //// List Views ////
      if (pCW->message == WM_LV_GETTEXT) {
      *g_szBuffer = NUL;
      int iItem = pCW->wParam;
      int iSubItem = iItem & 0xFFFF;
      iItem >>= 16;
      ListView_GetItemText(g_hWnd, iItem, iSubItem, g_szBuffer,
      MAX_DATA_BUF);
      UnhookWindowsHookEx(g_hHook);
      ......

      --End of code--

      So you treat pCW->wParam as a double word, which has iItem and
      iSubItem in it. It probably works fine (I didn't test it), but I am
      wondering if we can use pCW->lParam to pass iSubItem as separate
      value. The code would look like this:

      #define pCW ((CWPSTRUCT*)lParam)
      LRESULT HookProc (int code, WPARAM wParam, LPARAM lParam)
      {
      //// List Views ////
      if (pCW->message == WM_LV_GETTEXT) {
      *g_szBuffer = NUL;
      int iItem = pCW->wParam;
      int iSubItem = pCW->lParam;
      ListView_GetItemText(g_hWnd, iItem, iSubItem, g_szBuffer,
      MAX_DATA_BUF);
      UnhookWindowsHookEx(g_hHook);
      ......

      --End of code--

      GetListViewContents would then look like this:

      sub GetListViewContents
      {
      my $lv = shift;
      my @res;
      my $item_count = GetListViewItemCount($lv);
      my $header = GetListViewHeader($lv);
      my $column_count = $header ? GetHeaderColumnCount($header) : 1;
      # Items are numbered from 0
      for my $item_index (0..$item_count-1)
      {
      # Sub-items are numbered from 1
      # push @res, [map(GetListViewItem($lv, $item_index << 16 | $_),
      # 1..$column_count)];
      # PK: Instead of lines above it would be:
      push @res, [map(GetListViewItem($lv, $item_index, $_ ),
      1..$column_count)];

      }
      return @res;
      }

      --End of code

      That would of course require some changes in other functions:
      GetListViewItem, GetLVItemText.

      What do you think?

      --Piotr
    • denishowe
      ... Yes, that works perfectly for me. MSDN had convinced me that I couldn t use lParam but I can no longer find the relevant page.
      Message 2 of 13 , Nov 8, 2005
      • 0 Attachment
        In perlguitest@yahoogroups.com, "Piotr Kaluski" <pkaluski@p...> wrote:

        > I am wondering if we can use pCW->lParam
        > to pass iSubItem as separate value.

        Yes, that works perfectly for me. MSDN had convinced me that I
        couldn't use lParam but I can no longer find the relevant page.
      Your message has been successfully submitted and would be delivered to recipients shortly.