📄 hfmtreedlg.cpp
字号:
// HFMTREEDlg.cpp : implementation file
//m_stringin
#include "stdafx.h"
#include "HFMTREE.h"
#include "HFMTREEDlg.h"
#include "qHFMTREE.cpp"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CHFMTREEDlg dialog
HFMTree m_hfmtree;
CHFMTREEDlg::CHFMTREEDlg(CWnd* pParent /*=NULL*/)
: CDialog(CHFMTREEDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CHFMTREEDlg)
m_disphfmtreedata = _T("");
m_hfmtreefname = _T("");
m_stringout = _T("");
m_radio_stringin = -1;
m_stringin = _T("");
m_stringlen = 0;
m_codelen = 0;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CHFMTREEDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CHFMTREEDlg)
DDX_Control(pDX, IDC_EDIT_STRINGOUT, m_edit_stringout);
DDX_Control(pDX, IDC_EDIT_STRINGIN, m_edit_stringin);
DDX_Text(pDX, IDC_EDIT_DISPHFMTREE, m_disphfmtreedata);
DDX_Text(pDX, IDC_EDIT_HFMTREEFNAME, m_hfmtreefname);
DDX_Text(pDX, IDC_EDIT_STRINGOUT, m_stringout);
DDX_Radio(pDX, IDC_RADIO_STRINGIN, m_radio_stringin);
DDX_Text(pDX, IDC_EDIT_STRINGIN, m_stringin);
DDX_Text(pDX, IDC_EDIT_STRINGLEN, m_stringlen);
DDX_Text(pDX, IDC_EDIT_CODELEN, m_codelen);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CHFMTREEDlg, CDialog)
//{{AFX_MSG_MAP(CHFMTREEDlg)
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON_HFMTREEFNAME, OnButtonHfmtreefname)
ON_BN_CLICKED(IDC_BUTTON_CREATEHFMTREE, OnButtonCreatehfmtree)
ON_EN_CHANGE(IDC_EDIT_STRINGIN, OnChangeEditStringin)
ON_BN_CLICKED(IDC_RADIO_STRINGIN, OnRadioStringin)
ON_BN_CLICKED(IDC_RADIO_STRINGOUT, OnRadioStringout)
ON_BN_CLICKED(IDC_BUTTON_STRING_CODE, OnButtonStringCode)
ON_BN_CLICKED(IDC_BUTTON_CODE_STRING, OnButtonCodeString)
ON_EN_CHANGE(IDC_EDIT_STRINGOUT, OnChangeEditStringout)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CHFMTREEDlg message handlers
BOOL CHFMTREEDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CHFMTREEDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CHFMTREEDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CHFMTREEDlg::OnButtonHfmtreefname()
{
CFileDialog dlg(true);
if(dlg.DoModal()==IDOK)
{
m_hfmtreefname=dlg.GetFileName();
UpdateData(false);
}
}
void CHFMTREEDlg::OnButtonCreatehfmtree()
{
if(m_hfmtreefname!="")
{
m_hfmtree.CreatHFMTree(m_hfmtreefname);
m_hfmtree.CreatHFMCode();
m_hfmtree.PrintHFMTree(m_disphfmtreedata);
UpdateData(false);
}
else
{
AfxMessageBox("未选文件,不能生成!");
}
m_edit_stringin.SetReadOnly(true);
m_edit_stringout.SetReadOnly(true);
m_radio_stringin=-1;
UpdateData(false);
}
void CHFMTREEDlg::OnChangeEditStringin()
{
OnButtonStringCode() ;
}
void CHFMTREEDlg::OnRadioStringin()
{
m_edit_stringin.SetReadOnly(false);
m_edit_stringout.SetReadOnly(true);
}
void CHFMTREEDlg::OnRadioStringout()
{
m_edit_stringin.SetReadOnly(true);
m_edit_stringout.SetReadOnly(false);
}
void CHFMTREEDlg::OnButtonStringCode()
{
UpdateData(true);
if(m_stringin!="")
{
m_hfmtree.String_Code(m_stringin,m_stringout);
m_stringlen=GetLength(m_stringin);
m_codelen=GetLength(m_stringout);
UpdateData(false);
}
}
void CHFMTREEDlg::OnButtonCodeString()
{
UpdateData(true);
if(m_stringout!="")
{
m_hfmtree.Code_String(m_stringout,m_stringin);
m_stringlen=GetLength(m_stringin);
m_codelen=GetLength(m_stringout);
UpdateData(false);
}
}
void CHFMTREEDlg::OnChangeEditStringout()
{
OnButtonCodeString();
}
int CHFMTREEDlg::GetLength(LPCTSTR m_str)
{
int len=0;
for(int i=0;m_str[i]!=0;i++)
{
if((m_str[i]!='\r')&&(m_str[i]!='\n'))
len++;
else
i++;
}
return len;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -