📄 colorpage.cpp
字号:
// ColorPage.cpp : implementation file
//
#include "stdafx.h"
#include "gtmpeg.h"
#include "ColorPage.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
IMPLEMENT_DYNCREATE(CColorPage, CPropertyPage)
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
CColorPage::CColorPage() : CPropertyPage(CColorPage::IDD)
{
//{{AFX_DATA_INIT(CColorPage)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
CColorPage::~CColorPage()
{
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CColorPage::SetChannel(int nChannel)
{
ASSERT(nChannel>=0);
m_nChannel=nChannel;
m_sSection.Format("Video_%d",m_nChannel+1);
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
void CColorPage::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CColorPage)
DDX_Control(pDX, IDC_SATURATION_EDIT, m_cSaturationEdit);
DDX_Control(pDX, IDC_SATURATION, m_cSaturation);
DDX_Control(pDX, IDC_HUE_EDIT, m_cHueEdit);
DDX_Control(pDX, IDC_HUE, m_cHue);
DDX_Control(pDX, IDC_CONTRAST_EDIT, m_cContrastEdit);
DDX_Control(pDX, IDC_CONTRAST, m_cContrast);
DDX_Control(pDX, IDC_BRIGHT_EDIT, m_cBrightEdit);
DDX_Control(pDX, IDC_BRIGHT, m_cBright);
//}}AFX_DATA_MAP
}
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
BEGIN_MESSAGE_MAP(CColorPage, CPropertyPage)
//{{AFX_MSG_MAP(CColorPage)
ON_BN_CLICKED(IDC_DEFAULT, OnDefault)
ON_NOTIFY(NM_CUSTOMDRAW, IDC_BRIGHT, OnCustomdrawBright)
ON_NOTIFY(NM_CUSTOMDRAW, IDC_CONTRAST, OnCustomdrawContrast)
ON_NOTIFY(NM_CUSTOMDRAW, IDC_SATURATION, OnCustomdrawSaturation)
ON_NOTIFY(NM_CUSTOMDRAW, IDC_HUE, OnCustomdrawHue)
ON_EN_UPDATE(IDC_BRIGHT_EDIT, OnUpdateBrightEdit)
ON_EN_UPDATE(IDC_CONTRAST_EDIT, OnUpdateContrastEdit)
ON_EN_UPDATE(IDC_HUE_EDIT, OnUpdateHueEdit)
ON_EN_UPDATE(IDC_SATURATION_EDIT, OnUpdateSaturationEdit)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////////////
BOOL CColorPage::OnInitDialog()
{
CPropertyPage::OnInitDialog();
CString sTxt;
sTxt.Format("%d频道颜色设置",m_nChannel+1);
SetWindowText(sTxt);
SetDlgItemInt(IDC_BRIGHT_EDIT,AfxGetApp()->GetProfileInt(m_sSection,"亮度",45));
SetDlgItemInt(IDC_CONTRAST_EDIT,AfxGetApp()->GetProfileInt(m_sSection,"对比度",75));
SetDlgItemInt(IDC_SATURATION_EDIT,AfxGetApp()->GetProfileInt(m_sSection,"饱和度",64));
SetDlgItemInt(IDC_HUE_EDIT,AfxGetApp()->GetProfileInt(m_sSection,"色调",0));
m_cSaturation.SetRange(-127,128,TRUE);
m_cHue.SetRange(-127,128,TRUE);
m_cContrast.SetRange(-127,128,TRUE);
m_cBright.SetRange(-127,128,TRUE);
m_cSaturation.SetPos(AfxGetApp()->GetProfileInt(m_sSection,"饱和度",64));
m_cHue.SetPos(AfxGetApp()->GetProfileInt(m_sSection,"色调",0));
m_cContrast.SetPos(AfxGetApp()->GetProfileInt(m_sSection,"对比度",75));
m_cBright.SetPos(AfxGetApp()->GetProfileInt(m_sSection,"亮度",45));
return TRUE;
}
/////////////////////////////////////////
//
/////////////////////////////////////////
void CColorPage::OnUpdateBrightEdit()
{
int nPos=GetDlgItemInt(IDC_BRIGHT_EDIT);
m_cBright.SetPos(nPos);
}
/////////////////////////////////////////
//
/////////////////////////////////////////
void CColorPage::OnUpdateSaturationEdit()
{
int nPos=GetDlgItemInt(IDC_SATURATION_EDIT);
m_cSaturation.SetPos(nPos);
}
/////////////////////////////////////////
//
/////////////////////////////////////////
void CColorPage::OnUpdateHueEdit()
{
int nPos=GetDlgItemInt(IDC_HUE_EDIT);
m_cHue.SetPos(nPos);
}
/////////////////////////////////////////
//
/////////////////////////////////////////
void CColorPage::OnUpdateContrastEdit()
{
int nPos=GetDlgItemInt(IDC_CONTRAST_EDIT);
m_cContrast.SetPos(nPos);
}
/////////////////////////////////////////
//
/////////////////////////////////////////
void CColorPage::OnOK()
{
theApp.WriteProfileInt(m_sSection,"亮度", m_cBright.GetPos());
theApp.WriteProfileInt(m_sSection,"对比度", m_cContrast.GetPos());
theApp.WriteProfileInt(m_sSection,"饱和度", m_cSaturation.GetPos());
theApp.WriteProfileInt(m_sSection,"色调", m_cHue.GetPos());
CPropertyPage::OnOK();
}
/////////////////////////////////////////
//
/////////////////////////////////////////
void CColorPage::OnDefault()
{
m_cSaturation.SetPos(theApp.m_cSaturationDefault);
m_cHue.SetPos(theApp.m_cHueDefault);
m_cContrast.SetPos(theApp.m_cContrastDefault);
m_cBright.SetPos(theApp.m_cBrightDefault);
SetDlgItemInt(IDC_BRIGHT_EDIT,theApp.m_cBrightDefault);
SetDlgItemInt(IDC_CONTRAST_EDIT,theApp.m_cContrastDefault);
SetDlgItemInt(IDC_SATURATION_EDIT,theApp.m_cSaturationDefault);
SetDlgItemInt(IDC_HUE_EDIT,theApp.m_cHueDefault);
}
/////////////////////////////////////////
//
/////////////////////////////////////////
void CColorPage::OnCustomdrawBright(NMHDR* pNMHDR, LRESULT* pResult)
{
int nPos=m_cBright.GetPos();
SetDlgItemInt(IDC_BRIGHT_EDIT,nPos);
*pResult = 0;
}
/////////////////////////////////////////
//
/////////////////////////////////////////
void CColorPage::OnCustomdrawContrast(NMHDR* pNMHDR, LRESULT* pResult)
{
int nPos=m_cContrast.GetPos();
SetDlgItemInt(IDC_CONTRAST_EDIT,nPos);
*pResult = 0;
}
/////////////////////////////////////////
//
/////////////////////////////////////////
void CColorPage::OnCustomdrawSaturation(NMHDR* pNMHDR, LRESULT* pResult)
{
int nPos=m_cSaturation.GetPos();
SetDlgItemInt(IDC_SATURATION_EDIT,nPos);
*pResult = 0;
}
/////////////////////////////////////////
//
/////////////////////////////////////////
void CColorPage::OnCustomdrawHue(NMHDR* pNMHDR, LRESULT* pResult)
{
int nPos=m_cHue.GetPos();
SetDlgItemInt(IDC_HUE_EDIT,nPos);
*pResult = 0;
}
/////////////////////////////////////////
//
/////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -