)
{
base=19968-1;
end=40869;
}
else //(IDOK==ir)
{
strcpy(cstr,dlg.m_BuShou);
MultiByteToWideChar(CP_ACP,0,cstr,3,wstr,3);
i=0;
while(i<=idx)
{
if(abs(c[i].code-wstr[0])<=1) break;
++i;
}
if(i>idx)
{
AfxMessageBox("未知的部首!!!");
base=19968-1;
end=40869;
}
else //(i<=idx)
{
base=c[i].code-1;
end=40869;
}
}
++base;
if(base>40869) base=40869;
wstr[0]=base;
wstr[1]=0;
WideCharToMultiByte(CP_ACP,0,wstr,-1,cstr,3,0,0);
t=a[wstr[0]-19968];
ShowHanzi(cstr,wstr,t);
}
void CFindhzView::InitWordBushou()
{
char cstr[3],num[10],info[80];
long filen,i,j,t,n;
BYTE *buf;
FILE *fp;
a=new int[20902];
VERIFY(a!=0);
fp=fopen("bhsort2.dat","rb");
filen=_filelength(_fileno(fp));
buf=new BYTE[filen];
fread(buf,1,filen,fp);
fclose(fp);
i=n=0;
while(i<filen)
{
j=0;
while(buf[i]!='\r'&&buf[i+1]!='\n')
{
info[j]=buf[i];
++j;
++i;
}
info[j]='\0';
strncpy(num,info,5);
j=atoi(num);
strncpy(cstr,info+6,2);
t=atoi(info+9);
++n;
a[j-19968]=t;
while(('\r'==buf[i]||'\n'==buf[i])&&i<filen) ++i;
}
c=new SBh[300];
VERIFY(c!=0);
i=j=0;
c[j].code=i+19968;
c[j].cbs=a[i];
while(i<n-1)
{
if(a[i]<=a[i+1]) ++i;
else if(1<=a[i]-a[i+1]&&a[i]-a[i+1]<=5) ++i;
else //其它情况
{
++i;
++j;
c[j].code=i+19968;
c[j].cbs=a[i];
}
}
idx=j;
}
void CFindhzView::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
WCHAR wstr[3];
char cstr[3];
int t;
RedrawWindow();
if(VK_DOWN==nChar)
{
if(1==way)
{
++base;
if(base>20902-1) base=20902-1;
wstr[0]=b[base].code;
wstr[1]=0;
WideCharToMultiByte(CP_ACP,0,wstr,-1,cstr,3,0,0);
t=b[base].cbs;
}
else if(2==way)
{
++base;
if(base>40869) base=40869;
wstr[0]=base;
wstr[1]=0;
WideCharToMultiByte(CP_ACP,0,wstr,-1,cstr,3,0,0);
t=a[wstr[0]-19968];
}
ShowHanzi(cstr,wstr,t);
}
else if(VK_UP==nChar)
{
if(1==way)
{
--base;
if(base<0) base=0;
wstr[0]=b[base].code;
wstr[1]=0;
WideCharToMultiByte(CP_ACP,0,wstr,-1,cstr,3,0,0);
t=b[base].cbs;
}
else if(2==way)
{
--base;
if(base<19968) base=19968;
wstr[0]=base;
wstr[1]=0;
WideCharToMultiByte(CP_ACP,0,wstr,-1,cstr,3,0,0);
t=a[wstr[0]-19968];
}
ShowHanzi(cstr,wstr,t);
}
CView::OnKeyDown(nChar, nRepCnt, nFlags);
}
void CFindhzView::ShowHanzi(char cstr[],WCHAR wstr[],int t)
{
CClientDC cdc(this);
CFont NowFont,*pOldFont;
CBrush NowBru,*pOldBru;
LOGFONT lf;
char info[80];
sprintf(info,"笔画数:%d ",t);
cdc.TextOut(210,10,info);
sprintf(info,"Unicode编码:%d ",wstr[0]);
cdc.TextOut(210,30,info);
InitFont(&lf,-120,"宋体");
NowFont.CreateFontIndirect(&lf);
pOldFont=cdc.SelectObject(&NowFont);
NowBru.CreateSolidBrush(RGB(0xff,0xd7,0x00));
pOldBru=cdc.SelectObject(&NowBru);
cdc.SetBkMode(TRANSPARENT);
cdc.BeginPath();
cdc.TextOut(10,10,cstr);
cdc.EndPath();
cdc.StrokeAndFillPath();
DisplaySpell(&cdc,cstr);
cdc.SelectObject(pOldFont);
cdc.SelectObject(pOldBru);
}
void CFindhzView::InitFont(LOGFONT *pLF,int size,char face[])
{
ZeroMemory(pLF,sizeof(LOGFONT));
pLF->lfHeight=size;
pLF->lfWidth=0;
pLF->lfEscapement=0;
pLF->lfOrientation=0;
pLF->lfWeight=FW_NORMAL;
pLF->lfItalic=0;
pLF->lfUnderline=0;
pLF->lfStrikeOut=0;
pLF->lfCharSet=DEFAULT_CHARSET;
pLF->lfOutPrecision=OUT_DEFAULT_PRECIS;
pLF->lfClipPrecision=CLIP_DEFAULT_PRECIS;
pLF->lfQuality=DEFAULT_QUALITY;
pLF->lfPitchAndFamily=DEFAULT_PITCH;
strcpy(pLF->lfFaceName,face);
}
void CFindhzView::DisplaySpell(CDC *pDC,char cstr[])
{
UINT ListCount,ListID,ImeID,MaxKey;
char Ime