📄 复件 step1.cpp
字号:
// Step1.cpp : implementation file
//
#include "stdafx.h"
#include "Data_Trans.h"
#include "Data_TransDlg.h"
#include "Step1.h"
#include "VirtualInfoFile.h"
#include "FileDialogST.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CStep1 dialog
CStep1::CStep1(CWnd* pParent /*=NULL*/)
: CDialog(CStep1::IDD, pParent)
{
//{{AFX_DATA_INIT(CStep1)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_Dlg = (CData_TransDlg*)pParent;
}
void CStep1::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CStep1)
DDX_Text(pDX, IDC_EDIT1, m_111);
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CStep1, CDialog)
//{{AFX_MSG_MAP(CStep1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_BN_CLICKED(IDC_TEST, OnTest)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CStep1 message handlers
void CStep1::OnButton2()
{
// TODO: Add your control notification handler code here
CDialog::OnOK();
}
void CStep1::OnButton1()
{
// TODO: Add your control notification handler code here
CFileDialogST dlg(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_ALLOWMULTISELECT, _T("All files\0*.*\0"), this);
CString sPathName;
int nRetValue;
nRetValue = dlg.DoModal();
if (nRetValue == IDOK)
{
POSITION Pos;
Pos = dlg.GetStartPosition();
while (Pos != NULL)
{
sPathName = dlg.GetNextPathName(Pos);
} // while
/*sPathName = dlg.GetPathName();
MessageBox(sPathName, _T("GetPathName"), MB_ICONINFORMATION);
sPathName = dlg.GetFileName();
MessageBox(sPathName, _T("GetFileName"), MB_ICONINFORMATION);
sPathName = dlg.GetFileTitle();
MessageBox(sPathName, _T("GetFileTitle"), MB_ICONINFORMATION);
sPathName = dlg.GetFileExt();
MessageBox(sPathName, _T("GetFileExt"), MB_ICONINFORMATION);
sPathName = dlg.GetFileDir();
MessageBox(sPathName, _T("GetFileDir"), MB_ICONINFORMATION);
sPathName = dlg.GetFileDrive();
MessageBox(sPathName, _T("GetFileDrive"), MB_ICONINFORMATION);
*/
} // if
m_FileName = sPathName;
CData_TransApp* pApp = (CData_TransApp*)AfxGetApp();
m_FilePath = pApp->McgsGetPath(m_FileName);
}
void CStep1::OnTest() //弹出一个对话框选择对象名称
{
//默认的名称
//清楚原来的索引信息
for (int i=0;i<m_Dlg->m_arrayInfoFile.GetSize();++i)
{
delete m_Dlg->m_arrayInfoFile[i];
}
//对文件进行操作
CFile file;
try
{
if( !file.Open( m_FileName , CFile::modeRead ) )
{
return;
}
CByteArray Buff;
Buff.SetSize(file.GetLength());
file.Read(Buff.GetData(),file.GetLength());
COwnerArchive ar(COwnerArchive::storing);
ar.SvrWrite (Buff);
ar.SvrSeekToBegin ();
ar.SvrChangeMode (COwnerArchive::load);
int Size ;
ar >> Size; //对象数目
m_Dlg->m_arrayInfoFile.SetSize(Size);
m_Dlg->m_strArray.SetSize(Size);
for (int i=0; i<Size; ++i)
{
CString DataName;
ar >> DataName; //对象名
m_Dlg->m_arrayInfoFile[i] = new CVirtualInfoFile(DataName);
int idsize;
ar >> idsize; //对象的成员数
m_Dlg->m_arrayInfoFile[i]->m_GrpObjInfo.SetSize(idsize+2);
{ //添加毫秒和秒
m_Dlg->m_arrayInfoFile[i]->m_GrpObjInfo[0].m_name = "BECCA_Time";
m_Dlg->m_arrayInfoFile[i]->m_GrpObjInfo[0].m_type = 10;
m_Dlg->m_arrayInfoFile[i]->m_GrpObjInfo[1].m_name = "BECCA_TimeMS";
m_Dlg->m_arrayInfoFile[i]->m_GrpObjInfo[1].m_type = 1;
}
CString strName;
for (int j=0;j<idsize;++j)
{
int iType;
ar >> iType;
ar >> strName;
m_Dlg->m_arrayInfoFile[i]->m_GrpObjInfo[j+2].m_name = strName;
m_Dlg->m_arrayInfoFile[i]->m_GrpObjInfo[j+2].m_type = iType;
m_Dlg->m_strArray[i].Add(strName);
}
int FileNum;
ar >> m_Dlg->m_arrayInfoFile[i]->m_timeEnd;
ar >> m_Dlg->m_arrayInfoFile[i]->m_timeStart;
ar >> FileNum;
for (j=0; j<FileNum;++j)
{
CVirtualSaveStruct c;
c.m_strGroupObjName = DataName;
c.m_strDataSavePath = m_FilePath;
c.Serialize (ar);
m_Dlg->m_arrayInfoFile[i]->m_arraySaveInfo.Add(c);
}
}
}
catch(CException* e)
{
e->Delete();
file.Close();
return ;
}
m_Dlg->SetWizButton(0);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -