📄 wordsearch.cpp
字号:
// WORDSEARCH.cpp : implementation file
//
#include "stdafx.h"
#include "try_unic.h"
//#define _LIBIN
#include "WORDSEARCH.h"
#include "link_func.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// WORDSEARCH dialog
WORDSEARCH::WORDSEARCH(CWnd* pParent /*=NULL*/)
: CDialog(WORDSEARCH::IDD, pParent)
{
//{{AFX_DATA_INIT(WORDSEARCH)
m_word = _T("");
m_freq = _T("0");
//}}AFX_DATA_INIT
hptr=NULL;
}
void WORDSEARCH::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(WORDSEARCH)
DDX_Control(pDX, IDC_RELRASEITEMS, m_itemexist);
DDX_Text(pDX, IDC_WORD, m_word);
DDX_Text(pDX, IDC_WORDFREQ, m_freq);
//}}AFX_DATA_MAP
}
void WORDSEARCH::clear(void)
{
m_word = _T("");
m_freq = _T("0");
UpdateData(FALSE);
}
BEGIN_MESSAGE_MAP(WORDSEARCH, CDialog)
//{{AFX_MSG_MAP(WORDSEARCH)
ON_BN_CLICKED(IDSEARCH, OnSearch)
ON_BN_CLICKED(IDC_CHOOSEDIC, OnChoosedic)
ON_BN_CLICKED(IDC_RELRASEITEMS, OnRelraseitems)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// WORDSEARCH message handlers
//WordNode *hptr=NULL;
void WORDSEARCH::OnSearch()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
if(hptr==NULL){
AfxMessageBox(L"请加载词典!");
clear();
return;
}
if(m_word.IsEmpty()){
AfxMessageBox(L"请输入一个词条!");
return;
}
const wchar_t *word=(LPCWSTR)m_word;
WordNode *p=NULL;
p=search_w_order(hptr,word);
if(p==NULL) {
AfxMessageBox(L"词典中无此词条!");
clear();
return;
}
m_word=p->word;
m_freq.Format(L"%d",p->freq);
UpdateData(FALSE);
}
void WORDSEARCH::OnChoosedic()
{
// TODO: Add your control notification handler code here
int button=AfxMessageBox(L"请选择一个词表文件!",MB_YESNO);
if(button!=IDYES) return;
CFileDialog dlg(TRUE, L"txt", L"*.txt");
if(dlg.DoModal()!=IDOK) return;
CString path=dlg.GetPathName();
const wchar_t *filename=(LPCWSTR)path;
setlocale(LC_ALL,"chs");
hptr=add_Titems_order(filename);
// print_list(hptr,L"ree.txt");
clear();
}
void WORDSEARCH::OnRelraseitems()
{
// TODO: Add your control notification handler code here
clear();
if(hptr) delete_list2(hptr);
hptr=NULL;//删除后还得赋值,否则有错误
// m_itemexist.SetButtonStyle(WS_DISABLED,TRUE);
// m_itemexist.SetState(0);
//=WS_DISABLED ;WS_VISIBLE
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -