|
typedef struct _CGysetData
{
int f;
int n;
int w;
double c;
int fr;
int nr;
int wr;
double cr;
}CGysetData;
void CGongYiSet::OnSave()
{
CGysetData gysetdata;
CFile gyFile;
CString strL,strR,str;
strL="left data set";
strR="right data set";
UpdateData();
if(m_lstGyset.IsEmpty())
{ ZeroMemory(&gysetdata,sizeof(gysetdata));
if(GetDlgItem(IDC_R_GYSet)->GetWindowText(str),str==strR)
{
gysetdata.f=m_F;
gysetdata.n=m_N;
gysetdata.w=m_W;
gysetdata.c=m_C;
gyFile.Open(GYSETFILEPATH,CFile::modeRead|CFile::modeWrite);
// gyFile.SeekToEnd();
gyFile.Seek(sizeof(gysetdata)/2*(m_iCurPos),CFile::begin);
gyFile.Write(&gysetdata,sizeof(gysetdata)/2);
gyFile.Close();
m_lstGyset.AddTail(gysetdata);
UpdateData(false);
}
if(GetDlgItem(IDC_R_GYSet)->GetWindowText(str),str==strL)
{
gysetdata.fr=m_F;
gysetdata.nr=m_N;
gysetdata.wr=m_W;
gysetdata.cr=m_C;
gyFile.Open(GYSETFILEPATH,CFile::modeRead|CFile::modeWrite);
// gyFile.SeekToEnd();
gyFile.Seek(sizeof(gysetdata)/2*(m_iCurPos),CFile::end);
gyFile.Write(&gysetdata,sizeof(gysetdata)/2);
gyFile.Close();
m_lstGyset.AddTail(gysetdata);
UpdateData(false);}
}
else
{
ZeroMemory(&gysetdata,sizeof(gysetdata));
if(GetDlgItem(IDC_R_GYSet)->GetWindowText(str),str==strR)
{
gysetdata.f=m_F;
gysetdata.n=m_N;
gysetdata.w=m_W;
gysetdata.c=m_C;
gyFile.Open(GYSETFILEPATH,CFile::modeRead|CFile::modeWrite);
gyFile.Seek(sizeof(gysetdata)/2*(m_iCurPos),CFile::begin);
gyFile.Write(&gysetdata,sizeof(gysetdata)/2);
gyFile.Close();
m_lstGyset.SetAt(m_lstGyset.FindIndex(m_iCurPos),gysetdata);
}
if(GetDlgItem(IDC_R_GYSet)->GetWindowText(str),str==strL)
{
gysetdata.fr=m_F;
gysetdata.nr=m_N;
gysetdata.wr=m_W;
gysetdata.cr=m_Cwbsd;
gyFile.Open(GYSETFILEPATH,CFile::modeRead|CFile::modeWrite);
gyFile.Seek(sizeof(gysetdata)/2*(m_iCurPos),CFile::end);
gyFile.Write(&gysetdata,sizeof(gysetdata)/2);
gyFile.Close();
m_lstGyset.SetAt(m_lstGyset.FindIndex(m_iCurPos),gysetdata);
}
}
}
请问这个保存按钮的问题在哪里呀?为什么就是保存不了两套数据呢? |
|