解决了打开缓慢的问题,先显示主窗口,再加载诗词数据
下载地址
v2.6版本:增加了搜索诗人;在阅读模式是,点下拉菜单时发生变化;
诗词总数达到4000页 下载地址
v2.7版本: 改正了部分单引号不能查询和保存的错误;
下载地址
v2.7繁体版本:在繁体字操作系统下可正常显示诗词,用Unicode编码,诗词数据尚未改成繁体字
下载地址
v2.8版本下载:用Unicode编码,在不同语言的操作系统下可正常显示诗词
下载地址
推荐下载v2.9版本:支持繁体操作系统,诗词总页数达到4300页
下载地址

下载地址
很幼稚的方法,在debug下有错误,不过没更好的方法了,代码如下:


void CTangshiView::OnInitialUpdate()


{
CFormView::OnInitialUpdate();

GetParentFrame()->RecalcLayout();
ResizeParentToFit();
AddComboKindData();
SetFirstFont();
b_MidText=GetPrivateProfileInt("setting","midtext",0,IniFile);
SetTimer(100,0,NULL);
// KillTimer(100);
}

void CTangshiView::OnTimer(UINT nIDEvent)


{
if(nIDEvent==100)

{
CMainFrame* m_p=(CMainFrame*)AfxGetApp()->m_pMainWnd;
m_p->m_LeftTree->AddTreeData();
m_p->m_LeftTree->GetAllNum();
char mystrbuf[102];
CString strtemp_Dynasty,strtemp_Author,strtemp_Title;
GetPrivateProfileString("load","dynasty","当代",mystrbuf,102,IniFile);
strtemp_Dynasty=mystrbuf;
GetPrivateProfileString("load","author",NULL,mystrbuf,102,IniFile);
strtemp_Author=mystrbuf;
GetPrivateProfileString("load","title",NULL,mystrbuf,102,IniFile);
strtemp_Title=mystrbuf;
m_p->m_LeftTree->FirstLoad(strtemp_Dynasty,strtemp_Author,strtemp_Title);

// SASSSSSSSSSSSSSSSSSSSSSS
m_p->b_midplay=GetPrivateProfileInt("setting","midplay",1,IniFile);
GetPrivateProfileString("setting","mid","tangshi.mid",m_p->buf,1024,IniFile);
if(m_p->b_midplay)
m_p->PlaySoundAA(m_p->buf);
KillTimer(100);
//EEEEEEEEEEEEEEEEEEEEEEEEEEEEE
}
CFormView::OnTimer(nIDEvent);
}
搜索的代码:


void CSearch::OnButtonSearch()


{
UpdateData();
m_strSearch.TrimLeft();
if(m_strSearch=="")

{
MessageBox("请输入要搜索的诗词","唐诗宋词",64);
m_EditSearch.SetFocus();
return;
}
if(m_checkBaidu)

{
ShellExecute(NULL,NULL,"http://www.baidu.com/s?wd="+m_strSearch,NULL,NULL,SW_SHOWNORMAL);
// return;
}

if(m_checkBaike)

{
ShellExecute(NULL,NULL,"http://baike.baidu.com/list-php/dispose/searchword.php?word="+m_strSearch,NULL,NULL,SW_SHOWNORMAL);
// return;
}
CString sql_search, sql_or,sql_num;
sql_or=m_checkTitle?"d_title":m_checkAuthor?"d_author":"d_poetry";
myado.OnInitADO();//GROUP BY number HAVING COUNT(number) > 1
// sql_search.Format("select count(*) as num from t_poetry where %s like '%'%s'%'",sql_or,m_strSearch);
CString temp_strSearch;
temp_strSearch=m_strSearch;
temp_strSearch.Replace("'","''");
sql_search.Format("select distinct d_title,d_poetry,d_author from t_poetry where %s like '%s%s%s' order by d_author",sql_or,"%",temp_strSearch,"%");
myado.m_pRecordset.CreateInstance(__uuidof(Recordset));
myado.m_pRecordset->Open((_bstr_t)sql_search,myado.m_pConnection.GetInterfacePtr(),adOpenKeyset,adLockOptimistic,adCmdText);
if(myado.m_pRecordset->RecordCount>0)

{
int j;
j=0;
m_List.DeleteAllItems();
while(!myado.m_pRecordset->adoEOF)

{
m_List.InsertItem(j,"");
m_List.SetItemText(j,0,(char*)(_bstr_t)myado.m_pRecordset->GetCollect("d_title"));
m_List.SetItemText(j,1,(char*)(_bstr_t)myado.m_pRecordset->GetCollect("d_poetry"));
m_List.SetItemText(j,2,(char*)(_bstr_t)myado.m_pRecordset->GetCollect("d_author"));
myado.m_pRecordset->MoveNext();
j++;
}
CString str_myshow;
str_myshow.Format("共找到“%s”%d篇",m_strSearch,j);
SetDlgItemText(IDC_STATIC_SHOW,str_myshow);
}
else

{
SetDlgItemText(IDC_STATIC_SHOW,"未找到“"+m_strSearch+"”,百度一下吧!");
}
myado.ExitConnect();
}
posted on 2009-04-28 10:32
fly931 阅读(1409)
评论(5) 编辑 收藏 引用