📄 encoderconfig.cpp
字号:
// EncoderConfig.cpp : implementation file
//
#include "stdafx.h"
#include "alfa.h"
#include "EncoderConfig.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
/////////////////////////////////////////////////////////////////////////////
// CEncoderConfig dialog
CEncoderConfig::CEncoderConfig(CWnd* pParent /*=NULL*/)
: CDialog(CEncoderConfig::IDD, pParent)
{
//{{AFX_DATA_INIT(CEncoderConfig)
m_swap = 0;
m_input = 0;
m_channel = 0;
//}}AFX_DATA_INIT
}
void CEncoderConfig::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CEncoderConfig)
DDX_CBIndex(pDX, IDC_COMBO1, m_swap);
DDX_CBIndex(pDX, IDC_COMBO2, m_input);
DDX_CBIndex(pDX, IDC_COMBO3, m_channel);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CEncoderConfig, CDialog)
//{{AFX_MSG_MAP(CEncoderConfig)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_WM_SHOWWINDOW()
ON_CBN_SELCHANGE(IDC_COMBO3, OnSelchangeCombo3)
ON_CBN_DROPDOWN(IDC_COMBO3, OnDropdownCombo3)
ON_BN_CLICKED(IDC_BUTTON1, OnBtnOk)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEncoderConfig message handlers
void CEncoderConfig::OnButton2()
{
// TODO: Add your control notification handler code here
CMain * main=(CMain *)GetParent();
ShowWindow(FALSE);
main->dlgsysparamsel->ShowWindow(TRUE);
}
void CEncoderConfig::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();
OnSelchangeCombo3();
}
BOOL CEncoderConfig::CanSerialize()
{
// return(0==_access(DATA_FILE,1));
return(0==_access(DATA_FILE, 6));
}
void CEncoderConfig::Serialize(CArchive& ar)
{
m_channels.Serialize(ar);
}
void CEncoderConfig::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 CEncoderConfig::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 CEncoderConfig::OnSelchangeCombo3()
{
// TODO: Add your control notification handler code here
UpdateData();
Cchannel * pchannel=NULL;
if(m_channels.Lookup(m_channel,pchannel))
{
if(pchannel)
{
m_swap=pchannel->m_swap;
if(pchannel->m_input==1)
m_input=0;
else if(pchannel->m_input==2)
m_input=1;
else
m_input=2;
UpdateData(FALSE);
}
}
}
void CEncoderConfig::OnDropdownCombo3()
{
// 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_swap=m_swap;
if(m_input==0)
pchannel->m_input=1;
else if(m_input==1)
pchannel->m_input=2;
else
pchannel->m_input=4;
}
}
void CEncoderConfig::OnBtnOk()
{
// TODO: Add your control notification handler code here
OnDropdownCombo3();
SaveRecords();
CMain * main=(CMain *)GetParent();
ShowWindow(FALSE);
main->dlgsysparamsel->ShowWindow(TRUE);
}
BOOL CEncoderConfig::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 + -