📄 bianhuazhuanhuaview.cpp
字号:
// bianhuazhuanhuaView.cpp : implementation of the CBianhuazhuanhuaView class
//
#include "stdafx.h"
#include "bianhuazhuanhua.h"
#include "bianhuazhuanhuaDoc.h"
#include "bianhuazhuanhuaView.h"
#include "Crack.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CBianhuazhuanhuaView
IMPLEMENT_DYNCREATE(CBianhuazhuanhuaView, CView)
BEGIN_MESSAGE_MAP(CBianhuazhuanhuaView, CView)
//{{AFX_MSG_MAP(CBianhuazhuanhuaView)
ON_COMMAND(ID_xiugai, Onxiugai)
//}}AFX_MSG_MAP
// Standard printing commands
ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBianhuazhuanhuaView construction/destruction
CBianhuazhuanhuaView::CBianhuazhuanhuaView()
{
// TODO: add construction code here
}
CBianhuazhuanhuaView::~CBianhuazhuanhuaView()
{
}
BOOL CBianhuazhuanhuaView::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs
AfxGetModuleState()->m_dwVersion = 0x0601;
return CView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CBianhuazhuanhuaView drawing
void CBianhuazhuanhuaView::OnDraw(CDC* pDC)
{
CBianhuazhuanhuaDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
// TODO: add draw code for native data here
}
/////////////////////////////////////////////////////////////////////////////
// CBianhuazhuanhuaView printing
BOOL CBianhuazhuanhuaView::OnPreparePrinting(CPrintInfo* pInfo)
{
// default preparation
return DoPreparePrinting(pInfo);
}
void CBianhuazhuanhuaView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add extra initialization before printing
}
void CBianhuazhuanhuaView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// TODO: add cleanup after printing
}
/////////////////////////////////////////////////////////////////////////////
// CBianhuazhuanhuaView diagnostics
#ifdef _DEBUG
void CBianhuazhuanhuaView::AssertValid() const
{
CView::AssertValid();
}
void CBianhuazhuanhuaView::Dump(CDumpContext& dc) const
{
CView::Dump(dc);
}
CBianhuazhuanhuaDoc* CBianhuazhuanhuaView::GetDocument() // non-debug version is inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CBianhuazhuanhuaDoc)));
return (CBianhuazhuanhuaDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CBianhuazhuanhuaView message handlers
void CBianhuazhuanhuaView::OnInitialUpdate()
{
CView::OnInitialUpdate();
// TODO: Add your specialized code here and/or call the base class
}
void CBianhuazhuanhuaView::CalcWindowRect(LPRECT lpClientRect, UINT nAdjustType)
{
// TODO: Add your specialized code here and/or call the base class
CView::CalcWindowRect(lpClientRect, nAdjustType);
}
void CBianhuazhuanhuaView::Onxiugai()
{
// TODO: Add your command handler code here
CDaoDatabase m_pDatabase;
m_pDatabase.Open(_T("mengwen.mdb"));
CDaoRecordset m_pRecordset(&m_pDatabase);
CDaoTableDef td(&m_pDatabase);
td.Open(_T("vowel_a"));
m_pRecordset.Open(&td,dbOpenDynaset);
m_pRecordset.MoveFirst();
CDaoRecordset m_pvowel(&m_pDatabase);
CDaoTableDef tdvowel(&m_pDatabase);
tdvowel.Open(_T("fuyin"));
m_pvowel.Open(&tdvowel,dbOpenDynaset);
//m_pvowel.MoveFirst();
CString filename=_T("");
CString wordstr=_T("");
CString typestr=_T("");
CString strall=_T("");
CString curstr=_T("");
CString IDstr=_T("");
COleVariant var;
int n=0;
WCHAR curchar=0;
WCHAR nextchar=0;
WCHAR curcharstr=0;
WCHAR nextcharstr=0;
WCHAR number[32]={0x0061,0x0065,0x0069,0x0077,0x0076,0x006F,0x0075,0x006E,0x004E,0x0062,0x0070,0x0068,0x0067,0x006D,0x006C,0x0073,0x0078,0x0074,0x0064,0x0071,0x006A,0x0079,0x0072,0x0057,0x0066,0x006B,0x0063,0x007A,0x0048,0x0052,0x005A,0x0043};
//{a,e,i,w,v,o,u,n,N,b,p,h,g,m,l,s,x,t,d,q,j,y,r,W,f,k,c,z,H,R,Z,C}
CStringArray vowelArray;
//CStringArray consonantArray;
int mun=0;
while(!m_pRecordset.IsEOF())//mun<10
{ //mun++;
//CString stre;
//stre.Format(_T("%s%d"),_T("记录"),mun);
//AfxMessageBox(stre);
//AfxMessageBox(_T("进入循环"));
BOOL flag=FALSE;
filename=_T("");
wordstr=_T("");
typestr=_T("");
IDstr=_T("");
strall=_T("");
WCHAR kg=0x0020;
m_pRecordset.GetFieldValue(_T("phoneticize"),var);
filename=CCrack::strVARIANT(var);
filename.TrimRight(kg);
m_pRecordset.GetFieldValue(_T("word"),var);
wordstr=CCrack::strVARIANT(var);
wordstr.TrimRight(kg);
m_pRecordset.GetFieldValue(_T("type"),var);
typestr=CCrack::strVARIANT(var);
typestr.TrimRight(kg);
m_pRecordset.GetFieldValue(_T("ID"),var);
var.ChangeType(VT_I4);
int IDnum=var.intVal;
IDstr.Format(_T("%d"),IDnum);
//AfxMessageBox(IDstr);
IDstr=CCrack::strVARIANT(var);
strall=filename+_T(",")+wordstr+_T(",")+typestr+_T(",")+IDstr;
int charnum=filename.GetLength();
CString vf=_T("");
int ny=0;
for(int y=0;y<charnum;y++)
{
WCHAR sd=filename.GetAt(y);
if(sd!=0x005F)
{
ny++;
vf=vf+sd;
}
}
filename=_T("");
filename=vf;
charnum=ny;
int vowelnum=vowelArray.GetSize();
for(int u=0;u<vowelnum;u++)
{
flag=FALSE;
curstr=vowelArray.GetAt(u);
for(int r=0;r<curstr.GetLength();r++)
{
if(curstr.GetAt(r)==0x002C)
{//0x002C为_T(",")
curstr=curstr.Left(r);
break;
}
}
//AfxMessageBox(curstr);
int vcharnum=curstr.GetLength();
//去掉下划线
CString vg=_T("");
int ng=0;
for(int g=0;g<vcharnum;g++)
{
WCHAR sg=curstr.GetAt(g);
if(sg!=0x005F)
{
ng++;
vg=vg+sg;
}
}
//curstr=_T("");
curstr=vg;
vcharnum=ng;
//CString sl;
//sl.Format(_T("%d"),vcharnum);
//AfxMessageBox(curstr);
//AfxMessageBox(sl);
//sl.Format(_T("%d"),charnum);
//AfxMessageBox(filename);
// AfxMessageBox(sl);
int mix;
if(charnum<vcharnum)
{
mix=charnum;
}
else
{
mix=vcharnum;
}
//CString sw;
//sw.Format(_T("%s%d"),_T("MIX="),mix);
//AfxMessageBox(curstr);
//AfxMessageBox(sw);
for(int w=0;w<mix;w++)
{
int curxushu=0;
int strxushu=0;
int curxushunext=0;
int strxushunext=0;
curcharstr=curstr.GetAt(w);
curchar=filename.GetAt(w);
for(int l=0;l<32;l++)
{
if(curcharstr==number[l])
{
strxushu=l;
}
if(curchar==number[l])
{
curxushu=l;
}
}
if(curxushu==7)
{ //AfxMessageBox(_T("判断7"));
//stre.Format(_T("%d"),mix);
//AfxMessageBox(stre);
if((mix!=vcharnum)&&(mix==charnum)&&(w>=mix-1))
{ //数据库提取串小于字符数组串
//AfxMessageBox(_T("判断7第1"));
//AfxMessageBox(_T("判断7第1"));
nextcharstr=curstr.GetAt(w+1);
for(int l=0;l<32;l++)
{
if(nextcharstr==number[l])
{
strxushunext=l;
}
}
if (strxushu==7)
{
if((strxushunext>=0)&&(strxushunext<=6))
{
break;
}
else if((strxushunext>=7)&&(strxushunext<=31))
{
vowelArray.InsertAt(u,strall);
//AfxMessageBox(_T("添加字符串数组"));
flag=TRUE;
break;
}
}
else if(strxushu==8)
{
break;
}
}
else if((mix!=charnum)&&(mix==vcharnum)&&(w>=mix-1))
{//字符数组串小于数据库提取串
//AfxMessageBox(_T("判断7第2"));
nextchar=filename.GetAt(w+1);
for(int l=0;l<32;l++)
{
if(nextchar==number[l])
{
curxushunext=l;
}
}
if(strxushu==7)
{
if((curxushunext>=7)&&(curxushunext<=31))
{
break;
}
else if((curxushunext>=0)&&(curxushunext<=6))
{
vowelArray.InsertAt(u,strall);
//AfxMessageBox(_T("添加字符串数组"));
flag=TRUE;
break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -