www.pudn.com > speech1.rar > HolidaySet.cpp
// HolidaySet.cpp : implementation file
//
#include "stdafx.h"
#include "Specch.h"
#include "HolidaySet.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CHolidaySet dialog
CHolidaySet::CHolidaySet(CWnd* pParent /*=NULL*/)
: CDialog(CHolidaySet::IDD, pParent)
{
//{{AFX_DATA_INIT(CHolidaySet)
m_speakType = _T("");
m_speakContent = _T("");
m_warnType = -1;
//}}AFX_DATA_INIT
m_bChangeMusic = false ;
m_strVoiceType[0] = "Mary" ;
m_strVoiceType[1] = "Mike" ;
m_strVoiceType[2] = "Sam" ;
m_strVoiceType[3] = "Chinese" ;
}
void CHolidaySet::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CHolidaySet)
DDX_Control(pDX, IDC_COMBO1, m_comboVoice);
DDX_CBString(pDX, IDC_COMBO1, m_speakType);
DDX_Text(pDX, IDC_EDIT1, m_speakContent);
DDX_Radio(pDX, IDB_BLEBCUE, m_warnType);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CHolidaySet, CDialog)
//{{AFX_MSG_MAP(CHolidaySet)
ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
ON_WM_PAINT()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CHolidaySet message handlers
BOOL CHolidaySet::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
// 在CComboBox框中加入可选择的声音类型
for (int j = 0 ; j < 4 ; j++)
{
m_comboVoice.AddString(m_strVoiceType[j]) ;
}
m_comboVoice.SetCurSel(m_type) ;
// ((CBitmapButton*)GetDlgItem(IDB_BLEBCUE))->SetButtonStyle()
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CHolidaySet::OnOK()
{
// TODO: Add extra validation here
m_type = ((CComboBox*)GetDlgItem(IDC_COMBO1))->GetCurSel() ;
CDialog::OnOK();
}
void CHolidaySet::OnBrowse()
{
// TODO: Add your control notification handler code here
CFileDialog fileDlg(true , NULL , NULL , OFN_HIDEREADONLY ,
"波形声音文件(*.wav)|*.wav|所有文件(*.*)|*.*||") ;
if(fileDlg.DoModal() == IDOK)
{
m_bChangeMusic = true ;
m_musicPath = fileDlg.GetPathName() ;
UpdateData(FALSE) ;
}
}
void CHolidaySet::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
// CRect rect;
// GetClientRect(&rect);
// dc.FillSolidRect(rect,RGB(255,255,255)); //setting the background color
HBITMAP hbitmap = ::LoadBitmap(::AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BITMAP6));
//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,190,85,300,500,SRCCOPY);
//Delete the memory dc and the bitmap
::DeleteDC(hMemDC);
::DeleteObject(hbitmap);
// Do not call CDialog::OnPaint() for painting messages
}