📄 netctlvideoparadlg.cpp
字号:
// VideoParaDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Sample.h"
#include "NetCtlVideoParaDlg.h"
#include "NetRemoteCtrlDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern CNetRemoteCtrlDlg *pNetRemoteCtlDlg;
extern USER_DVR_PARAMETER *Con_pDVRPara;
extern LoginParam m_LoginParam;
VideoParam m_VideoParam;
extern int ENGLISH;
////////////////
//extern l_SelectRecordPort ;
/////////////////////////////////////////////////////////////////////////////
// CNetCtlVideoParaDlg dialog
CNetCtlVideoParaDlg::CNetCtlVideoParaDlg(CWnd* pParent /*=NULL*/)
: CDialog(CNetCtlVideoParaDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CNetCtlVideoParaDlg)
m_allportcheck = FALSE;
m_chroma = 0;
m_contrast = 0;
m_luma = 0;
//}}AFX_DATA_INIT
pParent = NULL ;
}
void CNetCtlVideoParaDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CNetCtlVideoParaDlg)
DDX_Control(pDX, IDC_SLIDER_LUMA, m_cLuma);
DDX_Control(pDX, IDC_SLIDER_CONTRAST, m_cContrast);
DDX_Control(pDX, IDC_SLIDER_CHROMA, m_cChroma);
DDX_Control(pDX, IDC_COMBO_PORT, m_port_combo);
DDX_Check(pDX, IDC_CHK_ALLPORT, m_allportcheck);
DDX_Slider(pDX, IDC_SLIDER_CHROMA, m_chroma);
DDX_Slider(pDX, IDC_SLIDER_CONTRAST, m_contrast);
DDX_Slider(pDX, IDC_SLIDER_LUMA, m_luma);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CNetCtlVideoParaDlg, CDialog)
//{{AFX_MSG_MAP(CNetCtlVideoParaDlg)
ON_CBN_SELCHANGE(IDC_COMBO_PORT, OnSelchangeComboPort)
ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER_CHROMA, OnReleasedcaptureSliderChroma)
ON_NOTIFY(NM_CUSTOMDRAW, IDC_SLIDER_CHROMA, OnCustomdrawSliderChroma)
ON_NOTIFY(NM_CUSTOMDRAW, IDC_SLIDER_LUMA, OnCustomdrawSliderLuma)
ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER_LUMA, OnReleasedcaptureSliderLuma)
ON_NOTIFY(NM_CUSTOMDRAW, IDC_SLIDER_CONTRAST, OnCustomdrawSliderContrast)
ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER_CONTRAST, OnReleasedcaptureSliderContrast)
ON_BN_CLICKED(IDC_BTN_SETDEFVPARA, OnBtnSetdefvpara)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CNetCtlVideoParaDlg message handlers
BOOL CNetCtlVideoParaDlg::OnInitDialog()
{
char * l_Port;
char * l_VideoPara;
char * l_AllPort;
char * l_Lum;
char * l_Chroma;
char * l_Contrast;
char * l_Set;
if(ENGLISH)
{
l_Port=_T("Channel");
l_VideoPara=_T("Video Para");
l_AllPort=_T("All channel");
l_Lum=_T("Luminance");
l_Chroma=_T("Chroma");
l_Contrast=_T("Contrast");
l_Set=_T("Setup");
}
else
{
l_Port=_T("通道");
l_VideoPara=_T("视频参数");
l_AllPort=_T("所有通道");
l_Lum=_T("亮度");
l_Chroma=_T("色度");
l_Contrast=_T("对比度");
l_Set=_T("设置");
}
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_cLuma.SetTicFreq(20);
m_cLuma.SetRange(0,255);
m_cChroma.SetTicFreq(20);
m_cChroma.SetRange(0,255);
m_cContrast.SetTicFreq(20);
m_cContrast.SetRange(0,127);
m_port_combo.ResetContent() ;
///
if(Con_pDVRPara!=NULL)
{
for (int i=0;i<Con_pDVRPara->nPortNo ;i++)
{
CString str ;
str.Format("%s%02d",l_Port,i+1) ;
m_port_combo.AddString(str) ;
}
m_port_combo.SetCurSel(0);
OnSelchangeComboPort();
}
CWnd *pWnd;
pWnd=GetDlgItem(IDC_STATIC_VIDEOPARA);
pWnd->SetWindowText(l_VideoPara);
pWnd=GetDlgItem(IDC_STATIC_PORT);
pWnd->SetWindowText(l_Port);
pWnd=GetDlgItem(IDC_CHK_ALLPORT);
pWnd->SetWindowText(l_AllPort);
pWnd=GetDlgItem(IDC_STATIC_LUM);
pWnd->SetWindowText(l_Lum);
pWnd=GetDlgItem(IDC_STATIC_CHROMA);
pWnd->SetWindowText(l_Chroma);
pWnd=GetDlgItem(IDC_STATIC_CONTRAST);
pWnd->SetWindowText(l_Contrast);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CNetCtlVideoParaDlg::OnSelchangeComboPort()
{
// TODO: Add your control notification handler code here
// UINT m_chroma;
// UINT m_contrast;
// UINT m_luma;
CString str;
UpdateData(TRUE);
if (pNetRemoteCtlDlg->m_nDVRType <= 0)
{
BYTE portno;
portno=m_port_combo.GetCurSel();
m_luma=255-Con_pDVRPara->PortConfigEx[portno].VideoPara.nLuma ;
str.Format("%d",Con_pDVRPara->PortConfigEx[portno].VideoPara.nLuma);
GetDlgItem(IDC_STATIC_LUMAVALUE)->SetWindowText(str);
m_chroma=255-Con_pDVRPara->PortConfigEx[portno].VideoPara.nChroma ;
str.Format("%d",Con_pDVRPara->PortConfigEx[portno].VideoPara.nChroma);
GetDlgItem(IDC_STATIC_CHROMAVALUE)->SetWindowText(str);
m_contrast=127-Con_pDVRPara->PortConfigEx[portno].VideoPara.nContrast ;
str.Format("%d",Con_pDVRPara->PortConfigEx[portno].VideoPara.nContrast);
GetDlgItem(IDC_STATIC_CONTRASTVALUE)->SetWindowText(str);
}
else
{
int portno;
portno=m_port_combo.GetCurSel();
pNetRemoteCtlDlg->GetDvrParam(portno+1,0,PARA_TYPE_VIDEO,&m_VideoParam,sizeof(VideoParam));
::SetTimer(pNetRemoteCtlDlg->m_hWnd,100,200,NULL);
if(portno<MAXPORTNO)
{
m_luma = 255 - m_VideoParam.Brightness;
//m_luma=255-Con_pDVRPara->PortConfigEx[portno].VideoPara.nLuma ;
str.Format("%d", m_VideoParam.Brightness);
//str.Format("%d",Con_pDVRPara->PortConfigEx[portno].VideoPara.nLuma);
GetDlgItem(IDC_STATIC_LUMAVALUE)->SetWindowText(str);
m_chroma = 255 - m_VideoParam.chroma;
//m_chroma=255-Con_pDVRPara->PortConfigEx[portno].VideoPara.nChroma ;
str.Format("%d",m_VideoParam.chroma);
//str.Format("%d",Con_pDVRPara->PortConfigEx[portno].VideoPara.nChroma);
GetDlgItem(IDC_STATIC_CHROMAVALUE)->SetWindowText(str);
m_contrast = 127 - m_VideoParam.contrast;
//m_contrast=127-Con_pDVRPara->PortConfigEx[portno].VideoPara.nContrast ;
str.Format("%d", m_VideoParam.contrast);
//str.Format("%d",Con_pDVRPara->PortConfigEx[portno].VideoPara.nContrast);
GetDlgItem(IDC_STATIC_CONTRASTVALUE)->SetWindowText(str);
}
}
UpdateData(FALSE) ;
}
BOOL CNetCtlVideoParaDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
DWORD t1=0;
DWORD t2=0;
t1=pMsg->message;
t2=(DWORD)pMsg->wParam;
if(t1==WM_KEYDOWN&&(t2==VK_RETURN||t2==VK_ESCAPE))
return true;
return CDialog::PreTranslateMessage(pMsg);
}
void CNetCtlVideoParaDlg::Refresh()
{
char * l_Port;//=_T("Camera");
if(ENGLISH)
l_Port=_T("Channel");
else
l_Port=_T("通道");
m_port_combo.ResetContent() ;
///
if (pNetRemoteCtlDlg->m_nDVRType <= 0)
{
for (int i=0;i<Con_pDVRPara->nPortNo ;i++)
{
CString str ;
str.Format("%s%02d",l_Port,i+1) ;
m_port_combo.AddString(str) ;
}
}
else
{
for (int i=0;i<m_LoginParam.ChannelCount;i++)
{
CString str ;
str.Format("%s%02d",l_Port,i+1) ;
m_port_combo.AddString(str) ;
}
}
if (pNetRemoteCtlDlg->m_nDVRType <= 0)
{// 83 V6.05无恢复视频参数功能
((CButton *)GetDlgItem(IDC_BTN_SETDEFVPARA))->ShowWindow(FALSE);
}
else
((CButton *)GetDlgItem(IDC_BTN_SETDEFVPARA))->ShowWindow(TRUE);
m_port_combo.SetCurSel(0);
OnSelchangeComboPort();
}
void CNetCtlVideoParaDlg::SetParams()
{
char * l_SelectPort;
if(ENGLISH)
{
l_SelectPort=_T("Please select channel to set video para");
}
else
{
l_SelectPort=_T("请选择您欲设置视频参数的通道");
}
int i ;
BYTE portno;
UpdateData(TRUE) ;
if(m_allportcheck)
{
portno=0;
}
else
{
i = m_port_combo.GetCurSel() ;
if (i < 0)
{
// AfxMessageBox(l_SelectPort);
return ;
}
portno=i+1;
}
pNetRemoteCtlDlg->SetNetRemoteVideoPara(portno,255-m_luma,255-m_chroma,127-m_contrast) ;
if(Con_pDVRPara!=NULL)
{
if(portno!=0)
{
Con_pDVRPara->PortConfigEx[portno-1].VideoPara.nLuma=255-m_luma ;
Con_pDVRPara->PortConfigEx[portno-1].VideoPara.nChroma=255-m_chroma ;
Con_pDVRPara->PortConfigEx[portno-1].VideoPara.nContrast=127-m_contrast ;
}
else
{
for (i=0;i<Con_pDVRPara->nPortNo ;i++)
{
Con_pDVRPara->PortConfigEx[i].VideoPara.nLuma=255-m_luma ;
Con_pDVRPara->PortConfigEx[i].VideoPara.nChroma=255-m_chroma ;
Con_pDVRPara->PortConfigEx[i].VideoPara.nContrast=127-m_contrast ;
}
}
}
}
void CNetCtlVideoParaDlg::OnReleasedcaptureSliderChroma(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
SetParams();
*pResult = 0;
}
void CNetCtlVideoParaDlg::OnCustomdrawSliderChroma(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
CString str;
UpdateData(TRUE);
str.Format("%d",255-m_chroma);
GetDlgItem(IDC_STATIC_CHROMAVALUE)->SetWindowText(str);
*pResult = 0;
}
void CNetCtlVideoParaDlg::OnCustomdrawSliderLuma(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
CString str;
UpdateData(TRUE);
str.Format("%d",255-m_luma);
GetDlgItem(IDC_STATIC_LUMAVALUE)->SetWindowText(str);
*pResult = 0;
}
void CNetCtlVideoParaDlg::OnReleasedcaptureSliderLuma(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
SetParams();
*pResult = 0;
}
void CNetCtlVideoParaDlg::OnCustomdrawSliderContrast(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
CString str;
UpdateData(TRUE);
str.Format("%d",127-m_contrast);
GetDlgItem(IDC_STATIC_CONTRASTVALUE)->SetWindowText(str);
*pResult = 0;
}
void CNetCtlVideoParaDlg::OnReleasedcaptureSliderContrast(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
SetParams();
*pResult = 0;
}
void CNetCtlVideoParaDlg::OnBtnSetdefvpara()
{
int m_portno;
int i;
if(m_allportcheck)
{
m_portno=0;
}
else
{
i = m_port_combo.GetCurSel() ;
m_portno=i+1;
}
pNetRemoteCtlDlg->SetVideoParaDefault(m_portno);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -