CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jul 2003
    Location
    Korea
    Posts
    60

    Sorting and LVN_ITEMCHANGED

    Hi gurus,

    I create a class derived from CListCtrl. This class is like ListCtrl in Windows Explorer in Details View. You can create new file, rename, or delete, re-arrange, ....

    Now I have a problem. My class do some jobs when LVN_ITEMCHANGED is notified. When I re-order the list, the OnItemChanged is called many times that is equal to the Item Count. This made me annoyed and wasted time. If anyone know how to re-order the list without notifiying LVN_ITEMCHANGED, please let me know. Thanks in advanced.

    Ah, yeah, my class uses SortItems(...) function of CListCtrl to sort. Everything seems good except the above problem.
    Quang

  2. #2
    Join Date
    Feb 2002
    Posts
    5,757
    One solution is a boolean variable to temporarily disable the work done inside the message handler.

    Kuphryn

  3. #3
    Join Date
    Jul 2003
    Location
    Korea
    Posts
    60
    Thanks kuphryn for your quick answer. Before posting, I tried this solution. But LVN_ITEMCHANGED is notified when sorting has been finished. I think that when SortItems is returned, CListCtrl have item list in the sorted order, then CListCtrl remove all current items and add items in the sorted list. Now this time LVN_ITEMCHANGED is notified when each item is added. Is this correct?
    Quang

  4. #4
    Join Date
    Feb 2002
    Posts
    5,757
    Correct.

    Kuphryn

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