?? 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 + -