OSDN Git Service

Fix sf.net ticket #2225: Issue when deleting 'File or Folder' history in Open dialog...
authorTakashi Sawanaka <sdottaka@users.sourceforge.net>
Tue, 21 May 2019 12:05:19 +0000 (21:05 +0900)
committerTakashi Sawanaka <sdottaka@users.sourceforge.net>
Tue, 21 May 2019 12:05:19 +0000 (21:05 +0900)
Src/Common/SuperComboBox.cpp
Src/Common/SuperComboBox.h

index ca076e0..2719240 100644 (file)
@@ -158,6 +158,16 @@ int CSuperComboBox::InsertString(int nIndex, LPCTSTR lpszItem)
        }
 }
 
+int CSuperComboBox::DeleteString(int nIndex)
+{
+       if (m_bComboBoxEx && m_bExtendedFileNames &&
+           nIndex >= 0 && nIndex < static_cast<int>(m_sFullStateText.size()))
+       {
+               m_sFullStateText.erase(m_sFullStateText.begin() + nIndex);
+       }
+       return CComboBoxEx::DeleteString(nIndex);
+}
+
 int CSuperComboBox::FindString(int nStartAfter, LPCTSTR lpszString) const
 {
        
@@ -390,7 +400,13 @@ BOOL CSuperComboBox::PreTranslateMessage(MSG* pMsg)
                        {
                                int cursel = GetCurSel();
                                if (cursel != CB_ERR)
+                               {
                                        DeleteString(cursel);
+                                       if (cursel >= GetCount())
+                                               cursel = GetCount() - 1;
+                                       if (cursel >= 0)
+                                               SetCurSel(cursel);
+                               }
                                return FALSE; // No need to further handle this message
                        }
                }
index 6fab6ad..ddec4f3 100644 (file)
@@ -66,6 +66,7 @@ public:
        bool AttachSystemImageList();
        int AddString(LPCTSTR lpszItem);
        int InsertString(int nIndex, LPCTSTR lpszItem);
+       int DeleteString(int nIndex);
        int FindString(int nStartAfter, LPCTSTR lpszString) const;
        int GetLBTextLen(int nIndex) const;
        void GetLBText(int nIndex, CString &rString) const;