📄 makeworddlg.cpp
字号:
// MakeWordDlg.cpp : implementation file
//
#include "stdafx.h"
#include "HikerWBFunc.h"
#include "HikerWBUI.h"
#include "MakeWordDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CMakeWordDlg dialog
CMakeWordDlg::CMakeWordDlg(CWnd* pParent /*=NULL*/)
: CDialog(CMakeWordDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CMakeWordDlg)
m_csCode = _T("");
m_csWord = _T("");
//}}AFX_DATA_INIT
m_bNew = TRUE;
}
void CMakeWordDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CMakeWordDlg)
DDX_Text(pDX, IDC_EDIT_CODE, m_csCode);
DDX_Text(pDX, IDC_EDIT_WORD, m_csWord);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CMakeWordDlg, CDialog)
//{{AFX_MSG_MAP(CMakeWordDlg)
ON_WM_SHOWWINDOW()
ON_WM_CREATE()
ON_EN_CHANGE(IDC_EDIT_WORD, OnChangeEditWord)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CMakeWordDlg message handlers
void CMakeWordDlg::OnOK()
{
// TODO: Add extra validation here
UpdateData(TRUE);
CString csCap;
GetWindowText(csCap);
m_csCode.MakeLower();
if (m_csCode.GetLength() != 4)
{
::MessageBox(NULL, "码长必须等于4!", csCap, MB_OK|MB_ICONSTOP|MB_TOPMOST);
return;
}
if (m_csWord.GetLength() < 4 && (m_csWord.GetLength()%2) == 0)
{
::MessageBox(NULL, "词必须由二个以上汉字构成!", csCap, MB_OK|MB_ICONSTOP|MB_TOPMOST);
return;
}
if (m_bNew)
UINewWord(m_csCode, m_csWord);
else
UIDeleteWord(m_csCode, m_csWord);
CDialog::OnOK();
}
void CMakeWordDlg::OnShowWindow(BOOL bShow, UINT nStatus)
{
CDialog::OnShowWindow(bShow, nStatus);
// TODO: Add your message handler code here
if (m_bNew)
SetWindowText("造词");
else
SetWindowText("删除词");
CWnd* pWnd = GetDlgItem(IDC_EDIT_WORD);
pWnd->SetFocus();
}
int CMakeWordDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
// TODO: Add your specialized creation code here
CDC dc;
dc.CreateDC("DISPLAY", NULL, NULL, NULL);
int iw = dc.GetDeviceCaps(HORZRES);
int ih = dc.GetDeviceCaps(VERTRES);
dc.DeleteDC();
CRect rt;
GetWindowRect(&rt);
SetWindowPos(&CWnd::wndNoTopMost, iw/2-rt.Width()/2, ih/2-rt.Height()/2, rt.Width(), rt.Height(), SWP_HIDEWINDOW);
return 0;
}
void CMakeWordDlg::OnChangeEditWord()
{
// TODO: If this is a RICHEDIT control, the control will not
// send this notification unless you override the CDialog::OnInitDialog()
// function and call CRichEditCtrl().SetEventMask()
// with the ENM_CHANGE flag ORed into the mask.
// TODO: Add your control notification handler code here
UpdateData(TRUE);
CString code;
GeneCode((unsigned char*)(LPCSTR)m_csWord, (unsigned char*)code.GetBuffer(CODELEN));
code.ReleaseBuffer();
m_csCode = code;
UpdateData(FALSE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -