forked from bigmacd/trapreceiver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfigureSound.cpp
More file actions
149 lines (122 loc) · 2.99 KB
/
ConfigureSound.cpp
File metadata and controls
149 lines (122 loc) · 2.99 KB
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
143
144
145
146
147
148
149
#include "stdafx.h"
#include "traprcvr.h"
#include "ConfigureSound.h"
ConfigureSound::ConfigureSound(CWnd* pParent /*=NULL*/)
:CDialog(ConfigureSound::IDD, pParent)
{
//{{AFX_DATA_INIT(ConfigureSound)
mDuration = 1;
mMode = 0;
mFilename = _T("");
//}}AFX_DATA_INIT
}
ConfigureSound::ConfigureSound(int duration,
CString filename)
:CDialog(ConfigureSound::IDD, NULL),
mDuration(duration),
mFilename(filename),
mMode(0)
{
if (mDuration > 0)
mMode = 1;
}
void
ConfigureSound::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(ConfigureSound)
DDX_Control(pDX, IDC_SLIDERDURATION, mDurationSlider);
DDX_Control(pDX, IDC_STATICDURATIONLABEL, mDurationLabelWindow);
DDX_Slider(pDX, IDC_SLIDERDURATION, mDuration);
DDX_Radio(pDX, IDC_RADIOONCE, mMode);
DDX_Text(pDX, IDC_EDITFILENAME, mFilename);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(ConfigureSound, CDialog)
//{{AFX_MSG_MAP(ConfigureSound)
ON_BN_CLICKED(IDC_RADIOONCE, OnRadioOnce)
ON_BN_CLICKED(IDC_RADIOLOOP, OnRadioLoop)
ON_WM_HSCROLL()
ON_BN_CLICKED(IDC_BUTTONBROWSE, OnButtonBrowse)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BOOL
ConfigureSound::OnInitDialog()
{
CDialog::OnInitDialog();
mDurationSlider.SetRange(1, 30, TRUE);
if (mMode == 1)
{
CString label;
label.Format("%d Second", mDuration);
mDurationLabelWindow.SetWindowText(label);
mDurationSlider.ShowWindow(SW_SHOW);
mDurationLabelWindow.ShowWindow(SW_SHOW);
}
else
{
mDurationSlider.ShowWindow(SW_HIDE);
mDurationLabelWindow.ShowWindow(SW_HIDE);
}
return TRUE;
}
void
ConfigureSound::OnRadioOnce()
{
mMode = 0;
mDurationSlider.ShowWindow(SW_HIDE);
mDurationLabelWindow.ShowWindow(SW_HIDE);
}
void
ConfigureSound::OnRadioLoop()
{
mMode = 1;
if (mDuration == 0)
mDuration = 1;
CString label;
label.Format("%d Second", mDuration);
if (mDuration > 1)
label += "s";
mDurationSlider.ShowWindow(SW_SHOW);
mDurationLabelWindow.ShowWindow(SW_SHOW);
mDurationLabelWindow.SetWindowText(label);
mDurationSlider.SetPos(mDuration);
}
void
ConfigureSound::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
mDuration = ((CSliderCtrl*)pScrollBar)->GetPos();
CString label;
label.Format("%d Second", mDuration);
if (mDuration > 1)
label += "s";
mDurationLabelWindow.SetWindowText(label);
mDurationSlider.SetPos(mDuration);
CDialog::OnHScroll(nSBCode, nPos, pScrollBar);
}
void
ConfigureSound::OnButtonBrowse()
{
char dir[256];
GetCurrentDirectory(255, dir);
CString browseTitle = "Sound File";
CFileDialog dlg(TRUE,
_T("wav"),
"",
OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
_T("Sound Files (*.wav)|*.wav|All Files|*.*||"));
dlg.m_ofn.lpstrTitle = browseTitle;
if (dlg.DoModal() == IDOK)
{
mFilename = dlg.GetPathName();
}
UpdateData(FALSE);
SetCurrentDirectory(dir);
}
void
ConfigureSound::OnOK()
{
CDialog::OnOK();
if (mMode == 0)
mDuration = 0;
}