-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathRecentRooms.cpp
More file actions
93 lines (79 loc) · 1.65 KB
/
Copy pathRecentRooms.cpp
File metadata and controls
93 lines (79 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
// RecentRooms.cpp: implementation of the CRecentRooms class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include <no5tl\winfile.h>
#include <no5tl\mystring.h>
#include "RecentRooms.h"
using namespace NO5TL;
//
CRecentRooms::CRecentRooms()
{
m_bDirty = false;
m_pRooms = new CUniqueStringStack(20);
}
CRecentRooms::~CRecentRooms()
{
delete m_pRooms;
}
BOOL CRecentRooms::Read(LPCTSTR file)
{
CWinFile wf;
BOOL res;
res = wf.Create(file,OPEN_EXISTING,GENERIC_READ);
if(res){
CDataBuffer db;
res = wf.ReadAll(db);
if(res){
CStringToken st;
CString next;
db.AddNull();
st.Init(db.GetData(),"\r\n",true);
next = st.GetNext();
while(!next.IsEmpty()){
m_pRooms->Push(next);
next = st.GetNext();
}
}
}
else{
DWORD error = GetLastError();
res = TRUE;
}
return res;
}
BOOL CRecentRooms::Write(LPCTSTR file)
{
CWinFile wf;
BOOL res;
res = wf.Create(file,CREATE_ALWAYS,GENERIC_WRITE);
if(res){
const int count = m_pRooms->GetSize();
int i;
DWORD dummy;
CString sAll;
for(i=0;i<count && res && count < 20 ;i++){
const CString &s = (*m_pRooms)[i];
sAll += s;
sAll += "\r\n";
}
res = wf.Write((void *)((LPCTSTR)sAll),sAll.GetLength(),&dummy);
if(res)
m_bDirty = false;
}
return res;
}
void CRecentRooms::Add(LPCTSTR room)
{
m_pRooms->Push(room);
m_bDirty = true;
}
void CRecentRooms::FillCombo(HWND hWndCombo)
{
const int count = m_pRooms->GetSize();
int i;
CComboBox cb = hWndCombo;
for(i=0;i<count;i++){
cb.AddString(m_pRooms->operator[](i));
}
}