CardDlg.cpp
资源名称:语音程序.rar [点击查看]
上传用户:lczygg
上传日期:2007-07-03
资源大小:2947k
文件大小:5k
源码类别:
语音合成与识别
开发平台:
Visual C++
- // CardDlg.cpp : implementation file
- //
- #include "stdafx.h"
- #include "WordRecPDA.h"
- #include "CardDlg.h"
- #include "..\CommandEngine.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CCardDlg dialog
- CCardDlg::CCardDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CCardDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CCardDlg)
- m_strName = _T("");
- m_bUpdateBook = FALSE;
- m_bTestBatch = FALSE;
- m_strPinyin = _T("");
- //}}AFX_DATA_INIT
- }
- void CCardDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CCardDlg)
- DDX_Text(pDX, IDC_EDIT_NAME, m_strName);
- DDV_MaxChars(pDX, m_strName, 11);
- DDX_Text(pDX, IDC_EDIT_INFO, m_strPinyin);
- //}}AFX_DATA_MAP
- }
- BEGIN_MESSAGE_MAP(CCardDlg, CDialog)
- //{{AFX_MSG_MAP(CCardDlg)
- ON_BN_CLICKED(IDC_BUTTON_ADD, OnButtonAdd)
- ON_BN_CLICKED(IDC_BUTTON_DELETE, OnButtonDelete)
- ON_BN_CLICKED(IDC_BUTTON_BATCH, OnButtonBatch)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CCardDlg message handlers
- void CCardDlg::OnButtonAdd()
- {
- CString strMsg;
- UpdateData(TRUE);
- char strName[MAX_PATH], strPiny[MAX_PATH];
- strcpy(strName, m_strName);
- strcpy(strPiny, m_strPinyin);
- if (strlen(strName) == 0) return;
- else if (strlen(strName) > MAX_WORD_LENGTH*2){
- strMsg.Format("名字不能超过%d个字!", MAX_WORD_LENGTH);
- AfxMessageBox(strMsg);
- return;
- }
- for (unsigned int i=0; i < strlen(strName); i++){
- if (strName[i] >= 0){
- AfxMessageBox("请输入中文字符!", MB_OK, 0);
- return;
- }
- }
- //自动注音
- //if (SrAddWord(strName, NULL) == 0) {
- // AfxMessageBox("OK");
- // m_bUpdateBook = true;
- //}
- //else
- // AfxMessageBox("Failed");
- //半自动注音
- char* strPinyin[MAX_WORD_LENGTH];
- for (i=0; i < MAX_WORD_LENGTH; i++) {
- strPinyin[i] = new char[7];
- strcpy(strPinyin[i], "");
- }
- if (strcmp(strPiny, "") == 0) {
- if (SrAddWord(strName, strPinyin) == 0) {
- m_strPinyin = "