📄 propertydlg.cpp
字号:
// PropertyDlg.cpp : implementation file
//
#include "stdafx.h"
#include "TestOcx.h"
#include "PropertyDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CPropertyDlg dialog
CPropertyDlg::CPropertyDlg(CHVDevice& Device, CWnd* pParent /*=NULL*/):
CDialog(CPropertyDlg::IDD, pParent),
m_Device(Device)
{
//{{AFX_DATA_INIT(CPropertyDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
void CPropertyDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPropertyDlg)
// NOTE: the ClassWizard will add DDX and DDV calls here
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPropertyDlg, CDialog)
//{{AFX_MSG_MAP(CPropertyDlg)
ON_NOTIFY(NM_CUSTOMDRAW, IDC_SLIDERSHUTTER, OnCustomdrawSlidershutter)
ON_NOTIFY(NM_CUSTOMDRAW, IDC_SLIDERGAIN, OnCustomdrawSlidergain)
ON_NOTIFY(NM_CUSTOMDRAW, IDC_SLIDERU, OnCustomdrawSlideru)
ON_NOTIFY(NM_CUSTOMDRAW, IDC_SLIDERV, OnCustomdrawSliderv)
ON_CBN_SELCHANGE(IDC_COMBO_MODE, OnSelchangeComboMode)
ON_CBN_SELCHANGE(IDC_COMBOADCLEVEL, OnSelchangeComboadclevel)
ON_CBN_SELCHANGE(IDC_COMBO_BAYER, OnSelchangeComboBayer)
ON_CBN_SELCHANGE(IDC_COMBO_TYPE, OnSelchangeComboType)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CPropertyDlg message handlers
BOOL CPropertyDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
long Min = 0, Max = 0;
CString str;
int i = 0;
long Width = 0, Height = 0;
m_Device.GetPropertyValueRange(2, &Min, &Max);
CSliderCtrl *pSlider = (CSliderCtrl *)GetDlgItem(IDC_SLIDERSHUTTER);
pSlider->SetRange(Min, Max, TRUE);
pSlider->SetPos(m_Device.GetShutter());
CStatic *pStatic = (CStatic *)GetDlgItem(IDC_STATICMINSHUTTER);
str.Format("%d", Min);
pStatic->SetWindowText(str);
pStatic = (CStatic *)GetDlgItem(IDC_STATICMAXSHUTTER);
str.Format("%d", Max);
pStatic->SetWindowText(str);
CEdit *pEdit = (CEdit *)GetDlgItem(IDC_EDITSHUTTER);
str.Format("%d", m_Device.GetShutter());
pEdit->SetWindowText(str);
m_Device.GetPropertyValueRange(3, &Min, &Max);
pSlider = (CSliderCtrl *)GetDlgItem(IDC_SLIDERGAIN);
pSlider->SetRange(Min, Max, TRUE);
pSlider->SetPos(m_Device.GetGain());
pStatic = (CStatic *)GetDlgItem(IDC_STATICMINGAIN);
str.Format("%d", Min);
pStatic->SetWindowText(str);
pStatic = (CStatic *)GetDlgItem(IDC_STATICMAXGAIN);
str.Format("%d", Max);
pStatic->SetWindowText(str);
pEdit = (CEdit *)GetDlgItem(IDC_EDITGAIN);
str.Format("%d", m_Device.GetGain());
pEdit->SetWindowText(str);
pSlider = (CSliderCtrl *)GetDlgItem(IDC_SLIDERU);
pSlider->SetRange(10, 500, TRUE);
pSlider->SetPos(m_Device.GetGainB());
pStatic = (CStatic *)GetDlgItem(IDC_STATICMINU);
str.Format("%d", 10);
pStatic->SetWindowText(str);
pStatic = (CStatic *)GetDlgItem(IDC_STATICMAXU);
str.Format("%d", 500);
pStatic->SetWindowText(str);
pEdit = (CEdit *)GetDlgItem(IDC_EDITU);
str.Format("%d", m_Device.GetGainB());
pEdit->SetWindowText(str);
pSlider = (CSliderCtrl *)GetDlgItem(IDC_SLIDERV);
pSlider->SetRange(10, 500, TRUE);
pSlider->SetPos(m_Device.GetGainR());
pStatic = (CStatic *)GetDlgItem(IDC_STATICMINV);
str.Format("%d", 10);
pStatic->SetWindowText(str);
pStatic = (CStatic *)GetDlgItem(IDC_STATICMAXV);
str.Format("%d", 500);
pStatic->SetWindowText(str);
pEdit = (CEdit *)GetDlgItem(IDC_EDITV);
str.Format("%d", m_Device.GetGainR());
pEdit->SetWindowText(str);
CComboBox *pComboBox = (CComboBox *)GetDlgItem(IDC_COMBO_MODE);
m_Device.GetPropertyValueRange(1, &Min, &Max);
for (i = Min; i <= Max; ++i )
{
m_Device.GetSensorSize(i, &Width, &Height);
str.Format("Mode %d ( %d * %d )", i, Width, Height);
pComboBox->AddString(str);
}
pComboBox->SetCurSel(m_Device.GetResolution());
pComboBox = (CComboBox *)GetDlgItem(IDC_COMBOADCLEVEL);
for (i = 0; i < 4; ++i )
{
str.Format("ADC Level %d", i);
pComboBox->AddString(str);
}
pComboBox->SetCurSel(m_Device.GetADCLevel());
pComboBox = (CComboBox *)GetDlgItem(IDC_COMBO_BAYER);
pComboBox->AddString("Disabled");
pComboBox->AddString("Enabled ( GBRG )");
pComboBox->AddString("Enabled ( GRBG )");
pComboBox->AddString("Enabled ( BGGR )");
pComboBox->AddString("Enabled ( RGGB )");
pComboBox->SetCurSel(m_Device.GetBayerToRGBConversion());
pComboBox = (CComboBox *)GetDlgItem(IDC_COMBO_TYPE);
pComboBox->AddString("Fast");
pComboBox->AddString("Normal");
pComboBox->AddString("Best");
pComboBox->SetCurSel(m_Device.GetConversionType());
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CPropertyDlg::OnOK()
{
return;
}
BOOL CPropertyDlg::PreTranslateMessage(LPMSG lpMsg)
{
if ((lpMsg->message == WM_KEYDOWN) && (LOWORD(lpMsg->wParam) == VK_RETURN))
UpdateSlider(lpMsg->hwnd);
return CDialog::PreTranslateMessage(lpMsg);
}
void CPropertyDlg::UpdateSlider(HWND hwnd)
{
CSliderCtrl *pSlider = NULL;
CString str;
::GetWindowText(hwnd, (char *)(LPCTSTR)str, 256);
int pos = atoi(str);
if (hwnd == GetDlgItem(IDC_EDITSHUTTER)->m_hWnd)
pSlider = (CSliderCtrl *)GetDlgItem(IDC_SLIDERSHUTTER);
else if(hwnd == GetDlgItem(IDC_EDITGAIN)->m_hWnd)
pSlider = (CSliderCtrl *)GetDlgItem(IDC_SLIDERGAIN);
else if (hwnd == GetDlgItem(IDC_EDITU)->m_hWnd)
pSlider = (CSliderCtrl *)GetDlgItem(IDC_SLIDERU);
else if(hwnd == GetDlgItem(IDC_EDITV)->m_hWnd)
pSlider = (CSliderCtrl *)GetDlgItem(IDC_SLIDERV);
if (pSlider)
pSlider->SetPos(pos);
}
void CPropertyDlg::OnCustomdrawSlidershutter(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
CSliderCtrl *pSlider = (CSliderCtrl *)GetDlgItem(IDC_SLIDERSHUTTER);
m_Device.SetShutter(pSlider->GetPos());
CEdit *pEdit = (CEdit *)GetDlgItem(IDC_EDITSHUTTER);
CString str;
str.Format("%d", pSlider->GetPos());
pEdit->SetWindowText(str);
*pResult = 0;
}
void CPropertyDlg::OnCustomdrawSlidergain(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
CSliderCtrl *pSlider = (CSliderCtrl *)GetDlgItem(IDC_SLIDERGAIN);
m_Device.SetGain(pSlider->GetPos());
CEdit *pEdit = (CEdit *)GetDlgItem(IDC_EDITGAIN);
CString str;
str.Format("%d", pSlider->GetPos());
pEdit->SetWindowText(str);
*pResult = 0;
}
void CPropertyDlg::OnCustomdrawSlideru(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
CSliderCtrl *pSlider = (CSliderCtrl *)GetDlgItem(IDC_SLIDERU);
m_Device.SetGainB(pSlider->GetPos());
CEdit *pEdit = (CEdit *)GetDlgItem(IDC_EDITU);
CString str;
str.Format("%d", pSlider->GetPos());
pEdit->SetWindowText(str);
*pResult = 0;
}
void CPropertyDlg::OnCustomdrawSliderv(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
CSliderCtrl *pSlider = (CSliderCtrl *)GetDlgItem(IDC_SLIDERV);
m_Device.SetGainR(pSlider->GetPos());
CEdit *pEdit = (CEdit *)GetDlgItem(IDC_EDITV);
CString str;
str.Format("%d", pSlider->GetPos());
pEdit->SetWindowText(str);
*pResult = 0;
}
void CPropertyDlg::OnSelchangeComboMode()
{
// TODO: Add your control notification handler code here
CComboBox *pComboBox = (CComboBox *)GetDlgItem(IDC_COMBO_MODE);
m_Device.SetResolution(pComboBox->GetCurSel());
}
void CPropertyDlg::OnSelchangeComboadclevel()
{
// TODO: Add your control notification handler code here
CComboBox *pComboBox = (CComboBox *)GetDlgItem(IDC_COMBOADCLEVEL);
m_Device.SetADCLevel(pComboBox->GetCurSel());
}
void CPropertyDlg::OnSelchangeComboBayer()
{
// TODO: Add your control notification handler code here
CComboBox *pComboBox = (CComboBox *)GetDlgItem(IDC_COMBO_BAYER);
m_Device.SetBayerToRGBConversion(pComboBox->GetCurSel());
}
void CPropertyDlg::OnSelchangeComboType()
{
// TODO: Add your control notification handler code here
CComboBox *pComboBox = (CComboBox *)GetDlgItem(IDC_COMBO_TYPE);
m_Device.SetConversionType(pComboBox->GetCurSel());
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -