CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Apr 2002
    Location
    Australia
    Posts
    54

    Question CListCtrl multiple selection - a strange problem

    Hi,

    I have a CListCtrl inside a dialog. Each item in the list represents data about a particular person. Related to each person are a number of data files. What I am wanting to do is display the size of each person's data files (and the total size of all people's files) in the caption at the top of the dialog (ie: Using SetWindowText).

    Ok - so I have it working fine for the total files and partially working for the individual files. My problem is how to correctly capture the changes in selection on the list control. I am using the NM_CLICK (ie: OnClick...) and LVN_KEYDOWN notifications to recalculate the size when someone either clicks on another person or moves with the arrow or page up/page down keys. I need to use these notifications rather than LVN_ITEMCHANGED as this one was updating the size for every item in the selection rather than at the end of a multiple selection.

    I have trouble when I try and capture multiple selection using the page up/page down keys - I cannot work out how to catch the windows message at the right time... it will not show the correct total until I move to the next person. ie: I select a number of items in the list and the total is not correct until I move the arrow key up or down. Does this make sense? Can anyone help with this very annoying, but small issue? Also - if there is some easier or better way to do this please let me know ...

    thank you,
    em

    ps: I can provide more info if needed

  2. #2
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815
    Use LVN_ODSTATECHANGED instead of LVN_ITEMCHANGED, it will be called only once when a range of items change state.

  3. #3
    Join Date
    Apr 2002
    Location
    Australia
    Posts
    54
    Thanks for the reply. The idea sounds good, but when I tried to use it previously nothing happened at all. Is there anything extra about LVN_ODSTATECHANGED that I need to know?

    thanks again,
    Em

  4. #4
    Join Date
    Apr 2002
    Location
    Australia
    Posts
    54

    LVN_ODSTATECHANGED

    OK I have looked further into LVN_ODSTATECHANGED and it seems that it will only work when you use the LVS_OWNERDATA style for the list control. I am not using this, so was wondering if anyone knows of any alternatives... (or could tell me why I should use it??) It seems like such a simple thing to accomplish, yet I have tried many different ways of doing it and have not yet come up with something that works for all scenarios (ie: single mouse click, arrow move, multiple mouse selection, multiple arrow/page up/down selection etc).

    any help would be appreciated,
    thanks
    em

  5. #5
    Join Date
    Sep 2002
    Location
    14° 39'19.65"N / 121° 1'44.34"E
    Posts
    9,815
    Em, sorry, not much time, will answer tomorrow, Guido

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured