www.pudn.com > speech1.rar > SoundSet.cpp
// SoundSet.cpp : implementation file
//
#include "stdafx.h"
#include "Specch.h"
#include "SoundSet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSoundSet dialog
CSoundSet::CSoundSet(CWnd* pParent /*=NULL*/)
: CDialog(CSoundSet::IDD, pParent)
{
EnableAutomation();
//{{AFX_DATA_INIT(CSoundSet)
m_rate = 0 ;
m_volume = 50;
//}}AFX_DATA_INIT
}
void CSoundSet::OnFinalRelease()
{
// When the last reference for an automation object is released
// OnFinalRelease is called. The base class will automatically
// deletes the object. Add additional cleanup required for your
// object before calling the base class.
CDialog::OnFinalRelease();
}
void CSoundSet::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSoundSet)
DDX_Text(pDX, IDE_RATE, m_rate);
DDX_Text(pDX, IDE_VOLUME, m_volume);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSoundSet, CDialog)
//{{AFX_MSG_MAP(CSoundSet)
ON_BN_CLICKED(IDB_RATEADD, OnRateadd)
ON_BN_CLICKED(IDB_RATEREDUCE, OnRatereduce)
ON_BN_CLICKED(IDB_VOLUMEADD, OnVolumeadd)
ON_BN_CLICKED(IDB_VOLUMEREDUCE, OnVolumereduce)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
BEGIN_DISPATCH_MAP(CSoundSet, CDialog)
//{{AFX_DISPATCH_MAP(CSoundSet)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_DISPATCH_MAP
END_DISPATCH_MAP()
// Note: we add support for IID_ISoundSet to support typesafe binding
// from VBA. This IID must match the GUID that is attached to the
// dispinterface in the .ODL file.
// {212664F0-0589-4427-BF22-A718780DA419}
static const IID IID_ISoundSet =
{ 0x212664f0, 0x589, 0x4427, { 0xbf, 0x22, 0xa7, 0x18, 0x78, 0xd, 0xa4, 0x19 } };
BEGIN_INTERFACE_MAP(CSoundSet, CDialog)
INTERFACE_PART(CSoundSet, IID_ISoundSet, Dispatch)
END_INTERFACE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSoundSet message handlers
BOOL CSoundSet::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_rate = 0 ;
m_volume = 50 ;
// CString strVoice
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
long CSoundSet::GetRate()
{
return m_rate ;
}
long CSoundSet::GetVolume()
{
return m_volume ;
}
void CSoundSet::SetRate(long rate)
{
m_rate = rate ;
}
void CSoundSet::SetVolume(long volume)
{
m_volume = volume ;
}
void CSoundSet::OnRateadd()
{
// TODO: Add your control notification handler code here
long lT = GetRate() ;
if(lT < 10)
{
lT++ ;
m_rate = lT ;
}
else
{
MessageBox("语速已经是最快的了!") ;
}
UpdateData(FALSE) ;
}
void CSoundSet::OnRatereduce()
{
// TODO: Add your control notification handler code here
long lT = GetRate() ;
if (lT > -10)
{
lT-- ;
m_rate = lT ;
}
else
{
MessageBox("语速已经是最慢的了!") ;
}
UpdateData(FALSE) ;
}
void CSoundSet::OnVolumeadd()
{
// TODO: Add your control notification handler code here
long lT = 0 ;
lT = GetVolume() ;
if(lT < 100)
{
lT += 10 ;
m_volume = lT ;
}
else
{
MessageBox("音量已经是最大的了!") ;
}
UpdateData(FALSE) ;
}
void CSoundSet::OnVolumereduce()
{
// TODO: Add your control notification handler code here
long lT = 0 ;
lT = GetVolume() ;
if (lT > 9)
{
lT -= 10 ;
m_volume = lT ;
}
else
{
MessageBox("音量已经是最小的了") ;
}
UpdateData(FALSE) ;
}
//DEL void CSoundSet::OnPaint()
//DEL {
//DEL CPaintDC dc(this); // device context for painting
//DEL
//DEL // TODO: Add your message handler code here
//DEL
//DEL // Do not call CDialog::OnPaint() for painting messages
//DEL }
void CSoundSet::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
HBITMAP hbitmap = ::LoadBitmap(::AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BITMAP9));
//create a memory DC
HDC hMemDC = ::CreateCompatibleDC(NULL);
//select the bitmap in the memory dc
SelectObject(hMemDC, hbitmap);
//copy the memory dc into the screen dc
::StretchBlt(dc.m_hDC, 0,0,400,500,hMemDC,5,20,250,300,SRCCOPY);
//Delete the memory dc and the bitmap
::DeleteDC(hMemDC);
::DeleteObject(hbitmap);
// Do not call CDialog::OnPaint() for painting messages
}