|
我定义的两个数据:
typedef struct _CData
{
int a;
int b;
}CData;
private:
CList m_lstset;
int m_iCurPos=0;
初始化里面是:
BOOL CGYSet::OnInitDialog()
CData setdata;
if()//数据文件存在,则读取
else //创建数据
if(m_lstset.GetCount()>0) //初始化界面显示
{
setdata=m_lstGyset.GetHead();
m_iCurPos=0;
m_edit1=setdata.a;
UpdateData(false);
}
保存里面是:
void CGongYiSet::OnSave()
{
// TODO: Add your control notification handler code here
CData setdata;
CFile gyFile;
UpdateData();
if(m_lstGyset.IsEmpty()) //添加操作
{
ZeroMemory(&gysetdata,sizeof(gysetdata));
setdata.a=m_Edit1;
gyFile.Open(GYSETFILEPATH,CFile::modeRead|CFile::modeWrite);
gyFile.SeekToEnd();
gyFile.Write(&gysetdata,sizeof(gysetdata));
gyFile.Close();
m_lstGyset.AddTail(gysetdata);
UpdateData(false);
}
else //编辑操作
{
ZeroMemory(&gysetdata,sizeof(gysetdata));
setdata.a=m_Edit1;
gyFile.Open(GYSETFILEPATH,CFile::modeRead|CFile::modeWrite);
gyFile.Seek(sizeof(gysetdata)*(m_iCurPos),CFile::begin);
gyFile.Write(&gysetdata,sizeof(gysetdata));
gyFile.Close();
m_lstGyset.SetAt(m_lstGyset.FindIndex(m_iCurPos),gysetdata);
UpdateData(false);
}
切换到b的按钮???
void CGongYiSet::OnRGYSet()
{
} |
|