📄 macparam.cpp
字号:
// MacParam.cpp : implementation file
//
#include "stdafx.h"
#include "alfa.h"
#include "MacParam.h"
#include "Main.h"
#include "io.h"
#define DATA_FILE _T("channel.bkp")
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMacParam dialog
CMacParam::CMacParam(CWnd* pParent /*=NULL*/)
: CDialog(CMacParam::IDD, pParent)
{
//{{AFX_DATA_INIT(CMacParam)
m_highlimit = 5000.0;
m_lowlimit = -5000.0;
m_highoffset = 0.0;
m_lowoffset = 0.0;
m_gain = 64;
m_rpm = 0;
m_channel = 0;
m_pos = 0;
m_command = 0;
m_ppr = 0;
m_gear = 0.0;
m_pitch = 0.0;
//}}AFX_DATA_INIT
}
void CMacParam::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMacParam)
DDX_Control(pDX, IDC_EDIT10, m_edt10);
DDX_Control(pDX, IDC_EDIT9, m_edt9);
DDX_Control(pDX, IDC_EDIT8, m_edt8);
DDX_Control(pDX, IDC_EDIT7, m_edt7);
DDX_Control(pDX, IDC_EDIT6, m_edt6);
DDX_Control(pDX, IDC_EDIT5, m_edt5);
DDX_Control(pDX, IDC_EDIT4, m_edt4);
DDX_Control(pDX, IDC_EDIT3, m_edt3);
DDX_Control(pDX, IDC_EDIT2, m_edt2);
DDX_Text(pDX, IDC_EDIT6, m_highlimit);
DDX_Text(pDX, IDC_EDIT8, m_lowlimit);
DDX_Text(pDX, IDC_EDIT7, m_highoffset);
DDX_Text(pDX, IDC_EDIT9, m_lowoffset);
DDX_Text(pDX, IDC_EDIT10, m_gain);
DDX_Text(pDX, IDC_EDIT2, m_rpm);
DDX_CBIndex(pDX, IDC_COMBO1, m_channel);
DDX_CBIndex(pDX, IDC_COMBO2, m_pos);
DDX_CBIndex(pDX, IDC_COMBO3, m_command);
DDX_Text(pDX, IDC_EDIT4, m_ppr);
DDX_Text(pDX, IDC_EDIT3, m_gear);
DDX_Text(pDX, IDC_EDIT5, m_pitch);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMacParam, CDialog)
//{{AFX_MSG_MAP(CMacParam)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_WM_SHOWWINDOW()
ON_CBN_SELCHANGE(IDC_COMBO1, OnSelchangeCombo1)
ON_CBN_DROPDOWN(IDC_COMBO1, OnDropdownCombo1)
ON_BN_CLICKED(IDC_BUTTON1, OnBtnOk)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMacParam message handlers
void CMacParam::OnButton2()
{
// TODO: Add your control notification handler code here
CMain * main=(CMain *)GetParent();
ShowWindow(FALSE);
main->dlgsysparamsel->ShowWindow(TRUE);
}
void CMacParam::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;
LoadRecords();
OnSelchangeCombo1();
}
BOOL CMacParam::CanSerialize()
{
return(0==_access(DATA_FILE,1));
}
void CMacParam::Serialize(CArchive& ar)
{
m_channels.Serialize(ar);
}
void CMacParam::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 CMacParam::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 CMacParam::OnSelchangeCombo1()
{
// TODO: Add your control notification handler code here
UpdateData();
Cchannel * pchannel=NULL;
if(m_channels.Lookup(m_channel,pchannel))
{
if(pchannel)
{
m_pos=pchannel->m_pos;
m_command=pchannel->m_command;
m_rpm=pchannel->m_rpm;
m_ppr=pchannel->m_ppr;
m_gear=pchannel->m_gear;
m_pitch=pchannel->m_pitch;
m_highlimit=pchannel->m_highlimit ;
m_lowlimit=pchannel->m_lowlimit ;
m_highoffset=pchannel->m_highoffset ;
m_lowoffset=pchannel->m_lowoffset;
m_gain=pchannel->m_gain;
UpdateData(FALSE);
}
}
}
void CMacParam::OnDropdownCombo1()
{
// TODO: Add your control notification handler code here
UpdateData();
Cchannel * pchannel=NULL;
if(!m_channels.Lookup(m_channel,pchannel))
{
pchannel=new Cchannel;
m_channels.SetAt(m_channel,pchannel);
}
if(pchannel)
{
pchannel->m_channel=m_channel;
pchannel->m_pos=m_pos;
pchannel->m_command=m_command;
pchannel->m_rpm=m_rpm;
pchannel->m_ppr=m_ppr;
pchannel->m_gear=m_gear;
pchannel->m_pitch=m_pitch;
pchannel->m_highlimit =m_highlimit;
pchannel->m_lowlimit =m_lowlimit;
pchannel->m_highoffset =m_highoffset;
pchannel->m_lowoffset =m_lowoffset;
pchannel->m_gain=m_gain;
}
}
void CMacParam::OnBtnOk()
{
// TODO: Add your control notification handler code here
OnDropdownCombo1();
SaveRecords();
CMain * main=(CMain *)GetParent();
ShowWindow(FALSE);
main->dlgsysparamsel->ShowWindow(TRUE);
}
BOOL CMacParam::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 + -