twain3.0/huagao/CFeedPaperPage.cpp

200 lines
5.2 KiB
C++

// CFeedPaperPage.cpp: 实现文件
//
#include "stdafx.h"
#include "CFeedPaperPage.h"
#include "afxdialogex.h"
#include "resource.h"
#include <vector>
std::vector<int> g400hiden =
{
IDC_CKBINDINGDETECT ,
IDC_CKSKEWDETECT,
IDC_LBSDL,
IDC_SLDDETECTLEVEL,
IDC_LBSDR,
};
static std::vector<CString> lowpowermode
{
_T("不休眠"),
_T("5分钟"),
_T("10分钟"),
_T("20分钟"),
_T("30分钟"),
_T("60分钟"),
_T("120分钟"),
_T("240分钟"),
};
// CFeedPaperPage 对话框
IMPLEMENT_DYNAMIC(CFeedPaperPage, CTabPageSSL)
CFeedPaperPage::CFeedPaperPage(/*std::function<void()> datachange,*/CWnd* pParent /*=nullptr*/)
: CTabPageSSL(IDD_PAGEFEEDPAPER, pParent)
, m_radioGroupScanMode(0)
, m_cbDoublePaper(FALSE)
, m_cbStaple(FALSE)
, m_cbRotation(FALSE)
, m_cbSkew(FALSE)
//, m_datachange(datachange)
{
}
CFeedPaperPage::~CFeedPaperPage()
{
}
void CFeedPaperPage::DoDataExchange(CDataExchange* pDX)
{
CTabPageSSL::DoDataExchange(pDX);
DDX_Radio(pDX, IDC_RDCONSISTSCAN, m_radioGroupScanMode);
DDX_Check(pDX, IDC_CKULTRSONICDETECT, m_cbDoublePaper);
DDX_Check(pDX, IDC_CKBINDINGDETECT, m_cbStaple);
DDX_Check(pDX, IDC_CKBACKROTATION, m_cbRotation);
DDX_Check(pDX, IDC_CKSKEWDETECT, m_cbSkew);
DDX_Control(pDX, IDC_CMBORENTATION, m_cmBoxOrentation);
DDX_Control(pDX, IDC_SLDDETECTLEVEL, m_sldSkrewDetecttion);
DDX_Control(pDX, IDC_EDSCANNUM, m_editNum);
DDX_Control(pDX, IDC_DogEarDetection, dogear);
DDX_Control(pDX, IDC_SLIDER_DOGEAR, m_slider_dogear);
}
BOOL CFeedPaperPage::OnInitDialog()
{
CTabPageSSL::OnInitDialog();
m_radioGroupScanMode = 0;
OnInitcmBoxOrentation(0);
m_sldSkrewDetecttion.SetSlideRange(1, 5);
m_sldSkrewDetecttion.SetSlidePos(3);
m_slider_dogear.SetSlideRange(10, 300);
m_slider_dogear.SetSlidePos(50);
m_slider_dogear.SetTicFreq(50);
#ifndef G200
for (size_t i = 0; i < g400hiden.size(); i++)
{
GetDlgItem(g400hiden[i])->ShowWindow(FALSE);
}
((CComboBox*)GetDlgItem(IDC_CBLOWPOWERMODE))->ShowWindow(SW_HIDE);
((CStatic*)GetDlgItem(IDC_STATICLOWPM))->ShowWindow(SW_HIDE);
#endif // G200
for (int i = 0; i < lowpowermode.size(); i++)
((CComboBox*)GetDlgItem(IDC_CBLOWPOWERMODE))->InsertString(i, lowpowermode[i]);
((CComboBox*)GetDlgItem(IDC_CBLOWPOWERMODE))->SetCurSel(0);
return true;
}
BEGIN_MESSAGE_MAP(CFeedPaperPage, CTabPageSSL)
ON_BN_CLICKED(IDC_RDCONSISTSCAN, &CFeedPaperPage::OnBnClickedScanMode)
ON_BN_CLICKED(IDC_RDSPECIFYSCANNUM, &CFeedPaperPage::OnBnClickedScanMode)
ON_BN_CLICKED(IDC_CKSKEWDETECT, &CFeedPaperPage::OnBnClickedCkskewdetect)
ON_CBN_SELCHANGE(IDC_CMBORENTATION, &CFeedPaperPage::OnCbnSelchangeCmborentation)
ON_BN_CLICKED(IDC_DogEarDetection, &CFeedPaperPage::OnBnClickedDogeardetection)
END_MESSAGE_MAP()
BOOL CFeedPaperPage::PreTranslateMessage(MSG* pMsg)
{
// TODO: 在此添加专用代码和/或调用基类
if (pMsg->message == WM_CHAR)
{
CEdit* pEdit = (CEdit*)GetDlgItem(IDC_EDSCANNUM);
if (pMsg->hwnd == pEdit->m_hWnd)
{
CString strText;
pEdit->GetWindowText(strText);
int length = strText.GetLength();
if ((pMsg->wParam >= '0' && pMsg->wParam <= '9' || pMsg->wParam == '\b'))
return CDialog::PreTranslateMessage(pMsg);
else
return true;
}
}
return CDialog::PreTranslateMessage(pMsg);
}
// CFeedPaperPage 消息处理程序
void CFeedPaperPage::OnBnClickedScanMode()
{
UpdateData(TRUE);
CButton* m_tempBtn = ((CButton*)GetDlgItem(IDC_RDCONSISTSCAN));
m_editNum.SetWindowText(m_tempBtn->GetCheck()==TRUE?_T("-1"):_T("1"));
m_editNum.EnableWindow(m_radioGroupScanMode);
}
void CFeedPaperPage::FeedPaperPageUpdate(int val)
{
//CButton* m_tempBtn = (CButton*)(GetDlgItem(IDC_CKBACKROTATION));
////int ival = val;
//if (val == 0 || val == 4)//单面或对折
// m_tempBtn->SetCheck(0);
//BOOL enable = (val == 0 || val == 4);
//m_tempBtn->EnableWindow(!enable);
comboxduplux = val;
if ((val > 0) && (val < 4) && (m_cmBoxOrentation.GetCurSel() != 4))
{
((CButton*)(GetDlgItem(IDC_CKBACKROTATION)))->EnableWindow(TRUE);
}
else
{
((CButton*)(GetDlgItem(IDC_CKBACKROTATION)))->EnableWindow(FALSE);
((CButton*)(GetDlgItem(IDC_CKBACKROTATION)))->SetCheck(FALSE);
}
}
void CFeedPaperPage::FeedAutoDescrewUpdate(int val)
{
CComboBox* m_temp = (CComboBox*)(GetDlgItem(IDC_CMBORENTATION));
if (16 == val)
{
m_temp->SetCurSel(4);
}
}
void CFeedPaperPage::OnInitcmBoxOrentation(int selectIndex)
{
m_cmBoxOrentation.InsertString(0, _T(""));
m_cmBoxOrentation.InsertString(1, _T("90°"));
m_cmBoxOrentation.InsertString(2, _T("180°"));
m_cmBoxOrentation.InsertString(3, _T("-90°"));
m_cmBoxOrentation.InsertString(4, _T("自动文本方向识别°"));
m_cmBoxOrentation.SetCurSel(selectIndex);
}
void CFeedPaperPage::OnBnClickedCkskewdetect()
{
// TODO: 在此添加控件通知处理程序代码
UpdateData(TRUE);
if (m_cbSkew != 1)
m_sldSkrewDetecttion.SetPos(3);
m_sldSkrewDetecttion.EnableWindow(m_cbSkew);
}
void CFeedPaperPage::OnCbnSelchangeCmborentation()
{
// TODO: 在此添加控件通知处理程序代码
FeedPaperPageUpdate(comboxduplux);
}
void CFeedPaperPage::OnBnClickedDogeardetection()
{
// TODO: 在此添加控件通知处理程序代码
UpdateData(TRUE);
if (((CButton*)GetDlgItem(IDC_DogEarDetection))->GetCheck() != 1)
m_slider_dogear.EnableWindow(FALSE);
else
m_slider_dogear.EnableWindow(TRUE);
}