OSDN Git Service

Bugfix to update MRU list if invoked from command line.
authorDennis Lim <dlkj@users.sourceforge.net>
Mon, 8 Oct 2001 14:03:40 +0000 (14:03 +0000)
committerDennis Lim <dlkj@users.sourceforge.net>
Mon, 8 Oct 2001 14:03:40 +0000 (14:03 +0000)
Src/MainFrm.cpp
Src/MainFrm.h

index f75d10c..050db21 100644 (file)
@@ -601,6 +601,12 @@ BOOL CMainFrame::DoFileOpen(LPCTSTR pszLeft /*=NULL*/, LPCTSTR pszRight /*=NULL*
                bRecurse = dlg.m_bRecurse;
                strExt = dlg.m_strParsedExt;
        }
+       else
+       {
+               //save the MRU left and right files.
+               addToMru(pszLeft, _T("Files\\Left"));
+               addToMru(pszRight, _T("Files\\Right"));
+       }
 
 
        // check to make sure they are same type
@@ -985,3 +991,27 @@ add_regexp(struct regexp_list **reglist,
   r->next = *reglist;
   *reglist = r;
 }
+
+// utility function to update CSuperComboBox format MRU
+void CMainFrame::addToMru(LPCSTR szItem, LPCSTR szRegSubKey, UINT nMaxItems)
+{
+       CString s,s2;
+       UINT cnt = AfxGetApp()->GetProfileInt(szRegSubKey, "Count", 0);
+       ++cnt;  // add new string
+       if(cnt>nMaxItems)
+       {
+               cnt=nMaxItems;
+       }
+       // move items down a step
+       for (UINT i=cnt ; i!=0; --i)
+       {
+               s2.Format("Item_%d", i-1);
+               s = AfxGetApp()->GetProfileString(szRegSubKey, s2);
+               s2.Format("Item_%d", i);
+               AfxGetApp()->WriteProfileString(szRegSubKey, s2, s);
+       }
+       // add most recent item
+       AfxGetApp()->WriteProfileString(szRegSubKey, "Item_0", szItem);
+       // update count
+       AfxGetApp()->WriteProfileInt(szRegSubKey, "Count", cnt);
+}
index 3a7c9f9..7073d45 100644 (file)
@@ -125,6 +125,7 @@ protected:
        DECLARE_MESSAGE_MAP()
 
 private:
+       void addToMru(LPCSTR szItem, LPCSTR szRegSubKey, UINT nMaxItems = 20);
        // builds the regular expression list if the
        // user choose to ignore Ignore changes affecting only lines 
        // that match the specified regexp.