📄 videopage.cpp
字号:
// VideoPage.cpp : implementation file
//
#include "stdafx.h"
#include "gtmpeg.h"
#include "VideoPage.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
IMPLEMENT_DYNCREATE(CVideoPage, CPropertyPage)
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
CVideoPage::CVideoPage() : CPropertyPage(CVideoPage::IDD)
{
//{{AFX_DATA_INIT(CVideoPage)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
CVideoPage::~CVideoPage()
{
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CVideoPage::SetChannel(int nChannel)
{
ASSERT(nChannel>=0);
m_nChannel=nChannel;
m_sSection.Format("Video_%d",nChannel+1);
m_nVideoMode=AfxGetApp()->GetProfileInt(m_sSection,"视频信号源制式",1);
m_nRecordWay=AfxGetApp()->GetProfileInt(m_sSection,"录制模式",0);
m_nImageType=AfxGetApp()->GetProfileInt(m_sSection,"图像尺寸",0);
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CVideoPage::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CVideoPage)
DDX_Control(pDX, IDC_VIDEO_QUALITY_EDIT, m_cVideoQualityEdit);
DDX_Control(pDX, IDC_VIDEO_QUALITY, m_cVideoQuality);
DDX_Control(pDX, IDC_QUALITY_TXT, m_cQuality);
//}}AFX_DATA_MAP
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
BEGIN_MESSAGE_MAP(CVideoPage, CPropertyPage)
//{{AFX_MSG_MAP(CVideoPage)
ON_BN_CLICKED(IDC_NTSC, OnNtsc)
ON_BN_CLICKED(IDC_PAL, OnPal)
ON_BN_CLICKED(IDC_AUDIO, OnAudio)
ON_BN_CLICKED(IDC_QSIF, OnQsif)
ON_BN_CLICKED(IDC_SIF, OnSif)
ON_BN_CLICKED(IDC_VIDEO, OnVideo)
ON_BN_CLICKED(IDC_VIDEO_AUDIO, OnVideoAudio)
ON_NOTIFY(NM_CUSTOMDRAW, IDC_VIDEO_QUALITY, OnCustomdrawVideoQuality)
ON_EN_UPDATE(IDC_VIDEO_QUALITY_EDIT, OnUpdateVideoQualityEdit)
ON_BN_CLICKED(IDC_DEFAULT, OnDefault)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
BOOL CVideoPage::OnInitDialog()
{
CPropertyPage::OnInitDialog();
CString sCaption;
sCaption.Format("频道%d视频设置",m_nChannel+1);
SetWindowText(sCaption);
SetVideoMode();
SetRecordWay();
SetImageType();
if(m_nImageType==0)
{
SetDlgItemInt(IDC_VIDEO_QUALITY_EDIT,AfxGetApp()->GetProfileInt(m_sSection,"常量位速率值",500));
m_cVideoQuality.SetRange(192,2000,TRUE);
m_cVideoQuality.SetPos(AfxGetApp()->GetProfileInt(m_sSection,"常量位速率值",500));
}
else
{
SetDlgItemInt(IDC_VIDEO_QUALITY_EDIT,AfxGetApp()->GetProfileInt(m_sSection,"常量位速率值",163));
m_cVideoQuality.SetRange(64,2000,TRUE);
m_cVideoQuality.SetPos(AfxGetApp()->GetProfileInt(m_sSection,"常量位速率值",163));
}
SetDiskSpace();
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CVideoPage::SetDiskSpace()
{
double fSpace=(double)m_cVideoQuality.GetPos()*(double)0.439453125;
CString sTxt=RoundingToString(fSpace,2);
CString sCaption;
sCaption.Format("每小时需要 %s 兆硬盘",sTxt);
m_cQuality.SetWindowText(sCaption);
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CVideoPage::SetVideoMode()
{
CButton *pButton=(CButton *)GetDlgItem(IDC_NTSC);
pButton->SetCheck(m_nVideoMode==0);
pButton=(CButton *)GetDlgItem(IDC_PAL);
pButton->SetCheck(m_nVideoMode==1);
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CVideoPage::SetRecordWay()
{
CButton *pButton=(CButton *)GetDlgItem(IDC_VIDEO);
pButton->SetCheck(m_nRecordWay==0);
pButton=(CButton *)GetDlgItem(IDC_AUDIO);
pButton->SetCheck(m_nRecordWay==1);
pButton=(CButton *)GetDlgItem(IDC_VIDEO_AUDIO);
pButton->SetCheck(m_nRecordWay==2);
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CVideoPage::SetImageType()
{
CButton *pButton=(CButton *)GetDlgItem(IDC_SIF);
pButton->SetCheck(m_nImageType==0);
pButton=(CButton *)GetDlgItem(IDC_QSIF);
pButton->SetCheck(m_nImageType==1);
if(m_nImageType==0)
{
int nTmp=AfxGetApp()->GetProfileInt(m_sSection,"常量位速率值",500);
if(nTmp<192)
nTmp=192;
SetDlgItemInt(IDC_VIDEO_QUALITY_EDIT,nTmp);
m_cVideoQuality.SetRange(192,2000,TRUE);
m_cVideoQuality.SetPos(nTmp);
}
else
{
SetDlgItemInt(IDC_VIDEO_QUALITY_EDIT,AfxGetApp()->GetProfileInt(m_sSection,"常量位速率值",163));
m_cVideoQuality.SetRange(64,2000,TRUE);
m_cVideoQuality.SetPos(AfxGetApp()->GetProfileInt(m_sSection,"常量位速率值",163));
}
SetDiskSpace();
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CVideoPage::OnNtsc()
{
m_nVideoMode=0;
SetVideoMode();
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CVideoPage::OnPal()
{
m_nVideoMode=1;
SetVideoMode();
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CVideoPage::OnAudio()
{
m_nRecordWay=1;
SetRecordWay();
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CVideoPage::OnQsif()
{
m_nImageType=1;
SetImageType();
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CVideoPage::OnSif()
{
m_nImageType=0;
SetImageType();
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CVideoPage::OnVideo()
{
m_nRecordWay=0;
SetRecordWay();
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CVideoPage::OnVideoAudio()
{
m_nRecordWay=2;
SetRecordWay();
}
/////////////////////////////////////////
//
/////////////////////////////////////////
void CVideoPage::OnCustomdrawVideoQuality(NMHDR* pNMHDR, LRESULT* pResult)
{
int nPos=m_cVideoQuality.GetPos();
SetDlgItemInt(IDC_VIDEO_QUALITY_EDIT,nPos);
SetDiskSpace();
*pResult = 0;
}
/////////////////////////////////////////
//
/////////////////////////////////////////
void CVideoPage::OnUpdateVideoQualityEdit()
{
int nPos=GetDlgItemInt(IDC_VIDEO_QUALITY_EDIT);
m_cVideoQuality.SetPos(nPos);
SetDiskSpace();
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CVideoPage::OnOK()
{
AfxGetApp()->WriteProfileInt(m_sSection,"视频信号源制式",m_nVideoMode);
AfxGetApp()->WriteProfileInt(m_sSection,"录制模式",m_nRecordWay);
AfxGetApp()->WriteProfileInt(m_sSection,"图像尺寸",m_nImageType);
theApp.WriteProfileInt(m_sSection,"常量位速率值", m_cVideoQuality.GetPos());
CPropertyPage::OnOK();
}
/////////////////////////////////////////
//
/////////////////////////////////////////
void CVideoPage::OnDefault()
{
if(m_nImageType==0)
{
m_cVideoQuality.SetPos(500);
SetDlgItemInt(IDC_VIDEO_QUALITY_EDIT,500);
}
else
{
m_cVideoQuality.SetPos(163);
SetDlgItemInt(IDC_VIDEO_QUALITY_EDIT,163);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -