OSDN Git Service

Keep selected items visible in Folder Compare columns dialog.
authorKimmo Varis <kimmov@gmail.com>
Tue, 6 Nov 2007 17:18:15 +0000 (17:18 +0000)
committerKimmo Varis <kimmov@gmail.com>
Tue, 6 Nov 2007 17:18:15 +0000 (17:18 +0000)
Src/DirColsDlg.cpp
Src/DirColsDlg.h

index 0a2e6df..7bf6aab 100644 (file)
@@ -105,7 +105,16 @@ void CDirColsDlg::LoadLists()
        SortArrayToLogicalOrder();
        
        // Set first item to selected state
-       m_listColumns.SetItemState(0, LVIS_SELECTED, LVIS_SELECTED);
+       SelectItem(0);
+}
+
+/**
+ * @brief Select item in list.
+ * @param [in] index Index of item to select.
+ */
+void CDirColsDlg::SelectItem(int index)
+{
+       m_listColumns.SetItemState(index, LVIS_SELECTED, LVIS_SELECTED);
 }
 
 /**
@@ -176,14 +185,20 @@ void CDirColsDlg::MoveItem(int index, int newIndex)
  */
 void CDirColsDlg::MoveSelectedItems(BOOL bUp)
 {
+       int firstInd = -1;
        POSITION pos = m_listColumns.GetFirstSelectedItemPosition();
 
        while (pos)
        {
                int ind = m_listColumns.GetNextSelectedItem(pos);
                int newInd = bUp ? ind - 1: ind + 1;
+               
+               // Remember first item
+               if (firstInd == -1)
+                       firstInd = newInd;
                MoveItem(ind, newInd);
        }
+       m_listColumns.EnsureVisible(firstInd, FALSE);
 }
 
 /**
index 7d23338..64c50ba 100644 (file)
@@ -72,6 +72,7 @@ public:
 protected:
        void InitList();
        void LoadLists();
+       void SelectItem(int index);
        void LoadDefLists();
        void SortArrayToLogicalOrder();
        void MoveItem(int index, int newIndex);