-
Notifications
You must be signed in to change notification settings - Fork 63
/
DlgMidFilter.cpp
142 lines (118 loc) · 3.18 KB
/
DlgMidFilter.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
// DlgMidFilter.cpp : implementation file
//
#include "stdafx.h"
#include "DIPDemo.h"
#include "DlgMidFilter.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgMidFilter dialog
CDlgMidFilter::CDlgMidFilter(CWnd* pParent /*=NULL*/)
: CDialog(CDlgMidFilter::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgMidFilter)
m_iFilterType = -1;
m_iFilterH = 0;
m_iFilterMX = 0;
m_iFilterMY = 0;
m_iFilterW = 0;
//}}AFX_DATA_INIT
}
void CDlgMidFilter::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgMidFilter)
DDX_Radio(pDX, IDC_RAD1, m_iFilterType);
DDX_Text(pDX, IDC_EDIT_FH, m_iFilterH);
DDV_MinMaxInt(pDX, m_iFilterH, 1, 8);
DDX_Text(pDX, IDC_EDIT_FMX, m_iFilterMX);
DDX_Text(pDX, IDC_EDIT_FMY, m_iFilterMY);
DDX_Text(pDX, IDC_EDIT_FW, m_iFilterW);
DDV_MinMaxInt(pDX, m_iFilterW, 1, 8);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgMidFilter, CDialog)
//{{AFX_MSG_MAP(CDlgMidFilter)
ON_BN_CLICKED(IDC_RAD1, OnRad1)
ON_BN_CLICKED(IDC_RAD2, OnRad2)
ON_BN_CLICKED(IDC_RAD3, OnRad3)
ON_BN_CLICKED(IDC_RAD4, OnRad4)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgMidFilter message handlers
void CDlgMidFilter::OnRad1()
{
// 3×1模板
m_iFilterType = 0;
m_iFilterH = 3;
m_iFilterW = 1;
m_iFilterMX = 0;
m_iFilterMY = 1;
// 设置文本框不可用
(CEdit *) GetDlgItem(IDC_EDIT_FH)->EnableWindow(FALSE);
(CEdit *) GetDlgItem(IDC_EDIT_FW)->EnableWindow(FALSE);
(CEdit *) GetDlgItem(IDC_EDIT_FMX)->EnableWindow(FALSE);
(CEdit *) GetDlgItem(IDC_EDIT_FMY)->EnableWindow(FALSE);
// 更新
UpdateData(FALSE);
}
void CDlgMidFilter::OnRad2()
{
// 1×3模板
m_iFilterType = 1;
m_iFilterH = 1;
m_iFilterW = 3;
m_iFilterMX = 1;
m_iFilterMY = 0;
// 设置文本框不可用
(CEdit *) GetDlgItem(IDC_EDIT_FH)->EnableWindow(FALSE);
(CEdit *) GetDlgItem(IDC_EDIT_FW)->EnableWindow(FALSE);
(CEdit *) GetDlgItem(IDC_EDIT_FMX)->EnableWindow(FALSE);
(CEdit *) GetDlgItem(IDC_EDIT_FMY)->EnableWindow(FALSE);
// 更新
UpdateData(FALSE);
}
void CDlgMidFilter::OnRad3()
{
// 3×3模板
m_iFilterType = 2;
m_iFilterH = 3;
m_iFilterW = 3;
m_iFilterMX = 1;
m_iFilterMY = 1;
// 设置文本框不可用
(CEdit *) GetDlgItem(IDC_EDIT_FH)->EnableWindow(FALSE);
(CEdit *) GetDlgItem(IDC_EDIT_FW)->EnableWindow(FALSE);
(CEdit *) GetDlgItem(IDC_EDIT_FMX)->EnableWindow(FALSE);
(CEdit *) GetDlgItem(IDC_EDIT_FMY)->EnableWindow(FALSE);
// 更新
UpdateData(FALSE);
}
void CDlgMidFilter::OnRad4()
{
// 自定义模板
(CEdit *) GetDlgItem(IDC_EDIT_FH)->EnableWindow(TRUE);
(CEdit *) GetDlgItem(IDC_EDIT_FW)->EnableWindow(TRUE);
(CEdit *) GetDlgItem(IDC_EDIT_FMX)->EnableWindow(TRUE);
(CEdit *) GetDlgItem(IDC_EDIT_FMY)->EnableWindow(TRUE);
}
void CDlgMidFilter::OnOK()
{
// 获取用户设置(更新)
UpdateData(TRUE);
// 判断设置是否有效
if ((m_iFilterMX < 0) || (m_iFilterMX > m_iFilterW - 1) ||
(m_iFilterMY < 0) || (m_iFilterMY > m_iFilterH - 1))
{
// 提示用户参数设置错误
MessageBox("参数设置错误!", "系统提示" , MB_ICONINFORMATION | MB_OK);
// 返回
return;
}
// 退出
CDialog::OnOK();
}