OSDN Git Service

Strip SuperComboBox strings before saving
authorKimmo Varis <kimmov@gmail.com>
Sat, 15 Jul 2006 14:03:33 +0000 (14:03 +0000)
committerKimmo Varis <kimmov@gmail.com>
Sat, 15 Jul 2006 14:03:33 +0000 (14:03 +0000)
Src/Changes.txt
Src/Common/SuperComboBox.cpp

index 0d447fa..1cbb6b6 100644 (file)
@@ -2,6 +2,10 @@ Src\Changes.txt
 Add new items to top.
 (This summarizes all changes to all files under Src, including Src\Languages.)
 
+2006-07-15 Kimmo
+ Strip SuperComboBox strings before saving
+  Src/Common: SuperComboBox.cpp
+
 2006-07-14 WinMerge experimental release 2.5.5.3 (cvs)
 
 2006-07-14 Kimmo
index 00dd05b..e04fb94 100644 (file)
@@ -110,6 +110,15 @@ void CSuperComboBox::LoadState(LPCTSTR szRegSubKey, UINT nMaxItems)
        }
 }
 
+/** 
+ * @brief Saves strings in combobox.
+ * This function saves strings in combobox, in editbox and in dropdown.
+ * Whitespace characters are stripped from begin and end of the strings
+ * before saving. Empty strings are not saved. So strings which have only
+ * whitespace characters aren't save either.
+ * @param [in] szRegSubKey Registry subkey where to save strings.
+ * @param [in] nMaxItems Max number of strings to save.
+ */
 void CSuperComboBox::SaveState(LPCTSTR szRegSubKey, UINT nMaxItems)
 {
        CString strItem,s,s2;
@@ -126,8 +135,9 @@ void CSuperComboBox::SaveState(LPCTSTR szRegSubKey, UINT nMaxItems)
        for (i=0; i < cnt && idx < (int)nMaxItems; i++)
        {
                GetLBText(i, s);
-               if (s != strItem
-                       && !s.IsEmpty())
+               s.TrimLeft();
+               s.TrimRight();
+               if (s != strItem && !s.IsEmpty())
                {
                        s2.Format(_T("Item_%d"), idx);
                        AfxGetApp()->WriteProfileString(szRegSubKey, s2, s);