?? motionparam.cpp
字號:
// MotionParam.cpp : implementation file
//
#include "stdafx.h"
#include "alfa.h"
#include "MotionParam.h"
#include "Main.h"
#include "io.h"
#define DATA_FILE _T("public.bkp")
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMotionParam dialog
CMotionParam::CMotionParam(CWnd* pParent /*=NULL*/)
: CDialog(CMotionParam::IDD, pParent)
{
//{{AFX_DATA_INIT(CMotionParam)
m_acctime = 300.0f;
m_dectime = 300.0f;
m_unit = 0;
m_coordtype = 0;
m_acctype = 0;
m_dectype = 0;
m_speed = 1000.0;
//}}AFX_DATA_INIT
}
void CMotionParam::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMotionParam)
DDX_Control(pDX, IDC_EDIT3, m_edt3);
DDX_Control(pDX, IDC_EDIT2, m_edt2);
DDX_Control(pDX, IDC_EDIT1, m_edt1);
DDX_Text(pDX, IDC_EDIT1, m_acctime);
DDX_Text(pDX, IDC_EDIT2, m_dectime);
DDX_CBIndex(pDX, IDC_COMBO1, m_unit);
DDX_CBIndex(pDX, IDC_COMBO2, m_coordtype);
DDX_CBIndex(pDX, IDC_COMBO3, m_acctype);
DDX_CBIndex(pDX, IDC_COMBO4, m_dectype);
DDX_Text(pDX, IDC_EDIT3, m_speed);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMotionParam, CDialog)
//{{AFX_MSG_MAP(CMotionParam)
ON_WM_SHOWWINDOW()
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMotionParam message handlers
void CMotionParam::OnShowWindow(BOOL bShow, UINT nStatus)
{
CDialog::OnShowWindow(bShow, nStatus);
// TODO: Add your message handler code here
if(bShow!=1) return;
CMain * main=(CMain *)GetParent();
main->dlgcur=this;
if(CanSerialize()) {
LoadRecords();
m_unit=m_public.m_unit-1;
m_coordtype=m_public.m_coordtype;
if(m_public.m_acctype=='T') m_acctype=0;
else m_acctype=1;
if(m_public.m_dectype=='T') m_dectype=0;
else m_dectype=1;
m_acctime=m_public.m_acctime ;
m_dectime=m_public.m_dectime ;
m_speed=m_public.m_maxspeed ;
UpdateData(FALSE);
}
}
void CMotionParam::OnButton2()
{
// TODO: Add your control notification handler code here
CMain * main=(CMain *)GetParent();
ShowWindow(FALSE);
main->dlgsysparamsel->ShowWindow(TRUE);
}
BOOL CMotionParam::CanSerialize()
{
// return(0==_access(DATA_FILE,1));
return(0==_access(DATA_FILE, 6));
}
void CMotionParam::LoadRecords()
{
if(CanSerialize()) {
CFile file;
CFileException fe;
if(file.Open(DATA_FILE,CFile::modeRead|CFile::typeBinary,&fe)) {
CArchive ar(&file,CArchive::load);
Serialize(ar);
}
}
}
void CMotionParam::Serialize(CArchive& ar)
{
m_public.Serialize(ar);
}
void CMotionParam::SaveRecords()
{
UINT flag=CFile::modeWrite|CFile::typeBinary;
BOOL canSave=FALSE;
if(_access(DATA_FILE, 0)) {
flag|=CFile::modeCreate;
canSave=TRUE;
}
else canSave=CanSerialize();
if(canSave) {
CFile file;
CFileException fe;
if(file.Open(DATA_FILE, flag, &fe)) {
CArchive ar(&file, CArchive::store);
Serialize(ar);
}
}
}
void CMotionParam::OnButton1()
{
// TODO: Add your control notification handler code here
UpdateData();
m_public.m_maxspeed=m_speed;
m_public.m_acctime=m_acctime;
m_public.m_dectime=m_dectime;
m_public.m_unit=m_unit+1;
m_public.m_coordtype=m_coordtype;
if(m_acctype==0) m_public.m_acctype='T';
else m_public.m_dectype='S';
if(m_dectype==0) m_public.m_dectype='T';
else m_public.m_dectype='S';
CMain * main=(CMain *)GetParent();
main->dlgcard->UpdateData();
m_public.m_address =_tcstol(main->dlgcard->m_address, NULL, 16);
m_public.m_irq=main->dlgcard->m_irq;
m_public.m_interpolate =main->dlgcard->m_interpolate;
SaveRecords();
ShowWindow(FALSE);
main->dlgsysparamsel->ShowWindow(TRUE);
}
BOOL CMotionParam::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
h_SkinDialog.SubClassDialog(m_hWnd);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -