| 73 | } |
| 74 | |
| 75 | void |
| 76 | RecentItems::Add(LPCTSTR item) |
| 77 | { |
| 78 | int i; |
| 79 | |
| 80 | bool bSave = !NeverSaveHistory(); |
| 81 | |
| 82 | CString *lastitems = new CString[m_count]; |
| 83 | |
| 84 | ASSERT(lastitems); |
| 85 | if (!lastitems) |
| 86 | return; |
| 87 | |
| 88 | Populate(lastitems); |
| 89 | |
| 90 | CString itemname; |
| 91 | |
| 92 | int index = m_count-1; |
| 93 | |
| 94 | for (i = 0; i < m_count; i++) { |
| 95 | if (!lstrcmpi(item, lastitems[i])) { |
| 96 | index = i; |
| 97 | break; |
| 98 | } |
| 99 | } |
| 100 | |
| 101 | for (i = index; i >= 1; i--) { |
| 102 | AppendIndex(itemname, i); |
| 103 | if (bSave) { |
| 104 | theApp.WriteProfileStringW(m_section, itemname, lastitems[i - 1]); |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | AppendIndex(itemname, 0); |
| 109 | if (bSave) { |
| 110 | theApp.WriteProfileString(m_section, itemname, item); |
| 111 | } |
| 112 | |
| 113 | delete[] lastitems; |
| 114 | } |
no test coverage detected