summaryrefslogtreecommitdiffabout
path: root/PropsSounds.cpp
blob: a6f68d7aff3491b6738c6cd38c8c245fc4073625 (plain)
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
// PropsSounds.cpp : implementation file
//

#include "stdafx.h"
#include "PumpKIN.h"
#include "PropsSounds.h"
#include "PumpKINDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CPropsSounds property page

IMPLEMENT_DYNCREATE(CPropsSounds, CPropertyPage)

CPropsSounds::CPropsSounds() : CPropertyPage(CPropsSounds::IDD)
{
	//{{AFX_DATA_INIT(CPropsSounds)
	m_Abort = _T("");
	m_Success = _T("");
	m_Request = _T("");
	//}}AFX_DATA_INIT
}

CPropsSounds::~CPropsSounds()
{
}

void CPropsSounds::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CPropsSounds)
	DDX_Control(pDX, IDC_RING_PLAY, m_RequestPlayCtl);
	DDX_Control(pDX, IDC_RING_BROWSE, m_RequestBrowseCtl);
	DDX_Control(pDX, IDC_RING, m_RequestCtl);
	DDX_Control(pDX, IDC_FINISHED_PLAY, m_SuccessPlayCtl);
	DDX_Control(pDX, IDC_FINISHED_BROWSE, m_SuccessBrowseCtl);
	DDX_Control(pDX, IDC_FINISHED, m_SuccessCtl);
	DDX_Control(pDX, IDC_ABORTED_PLAY, m_AbortPlayCtl);
	DDX_Control(pDX, IDC_ABORTED_BROWSE, m_AbortBrowseCtl);
	DDX_Control(pDX, IDC_ABORTED, m_AbortCtl);
	DDX_CBString(pDX, IDC_ABORTED, m_Abort);
	DDX_CBString(pDX, IDC_FINISHED, m_Success);
	DDX_CBString(pDX, IDC_RING, m_Request);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CPropsSounds, CPropertyPage)
	//{{AFX_MSG_MAP(CPropsSounds)
	ON_BN_CLICKED(IDC_ABORTED_BROWSE, OnAbortedBrowse)
	ON_BN_CLICKED(IDC_FINISHED_BROWSE, OnFinishedBrowse)
	ON_BN_CLICKED(IDC_RING_BROWSE, OnRingBrowse)
	ON_BN_CLICKED(IDC_ABORTED_PLAY, OnAbortedPlay)
	ON_BN_CLICKED(IDC_FINISHED_PLAY, OnFinishedPlay)
	ON_BN_CLICKED(IDC_RING_PLAY, OnRingPlay)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CPropsSounds message handlers

BOOL CPropsSounds::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();
	
HICON hP = AfxGetApp()->LoadIcon(IDI_PLAY);
HICON hB = AfxGetApp()->LoadIcon(IDI_BROWSE);
	m_RequestPlayCtl.SetIcon(hP);
	m_SuccessPlayCtl.SetIcon(hP);
	m_AbortPlayCtl.SetIcon(hP);
	m_RequestBrowseCtl.SetIcon(hB);
	m_SuccessBrowseCtl.SetIcon(hB);
	m_AbortBrowseCtl.SetIcon(hB);
	
CPumpKINDlg* pd = (CPumpKINDlg*)AfxGetMainWnd();
//	ASSERT_KINDOF(CPumpKINDlg,pd);
	m_bnw=&pd->m_bnw;

	m_bnw->FillInCombo(&m_RequestCtl);
	m_bnw->FillInCombo(&m_SuccessCtl);
	m_bnw->FillInCombo(&m_AbortCtl);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CPropsSounds::OnAbortedBrowse() 
{
	Browse(m_AbortCtl);
}
void CPropsSounds::OnFinishedBrowse() 
{
	Browse(m_SuccessCtl);
}
void CPropsSounds::OnRingBrowse() 
{
	Browse(m_RequestCtl);
}

void CPropsSounds::OnAbortedPlay() 
{
	Play(m_AbortCtl);
}

void CPropsSounds::OnFinishedPlay() 
{
	Play(m_SuccessCtl);
}

void CPropsSounds::OnRingPlay() 
{
	Play(m_RequestCtl);
}

void CPropsSounds::Browse(CComboBox& ctl)
{
CString f;
	ctl.GetWindowText(f);
CString filter;
	filter.LoadString(IDS_FILTER_WAV);
CFileDialog fd(TRUE,NULL,(LPCTSTR)f,
			   OFN_EXPLORER|OFN_FILEMUSTEXIST|OFN_HIDEREADONLY
			   |OFN_LONGNAMES|OFN_NOCHANGEDIR|OFN_PATHMUSTEXIST,
			   filter,this);
CString title;
	title.LoadString(IDS_TITLE_WAV);
	fd.m_ofn.lpstrTitle=(LPCTSTR)title;
	if(fd.DoModal()==IDOK)
		ctl.SetWindowText(fd.GetPathName());
}

void CPropsSounds::Play(CComboBox& ctl)
{
CString s;
	ctl.GetWindowText(s);
CBellsNWhistles::Whistling w = m_bnw->StartSound(s);
	if(w){
		Sleep(5000);
		m_bnw->StopSound(w);
	}
}