📄 showcodedlg.cpp
字号:
// ShowCodeDlg.cpp : 实现文件
//
#include "stdafx.h"
#include "huffman.h"
#include "ShowCodeDlg.h"
#include ".\showcodedlg.h"
// CShowCodeDlg 对话框
IMPLEMENT_DYNAMIC(CShowCodeDlg, CDialog)
CShowCodeDlg::CShowCodeDlg(CWnd* pParent /*=NULL*/)
: CDialog(CShowCodeDlg::IDD, pParent)
{
}
CShowCodeDlg::~CShowCodeDlg()
{
}
void CShowCodeDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_SHOWCODELIST1, m_ctrSCList);
}
BEGIN_MESSAGE_MAP(CShowCodeDlg, CDialog)
END_MESSAGE_MAP()
// CShowCodeDlg 消息处理程序
BOOL CShowCodeDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_ctrSCList.InsertColumn(1,_T("字符"),LVCFMT_LEFT,48);
m_ctrSCList.InsertColumn(2,_T("出现次数"),LVCFMT_LEFT,48);
m_ctrSCList.InsertColumn(3,_T("百分比"),LVCFMT_LEFT,72);
m_ctrSCList.InsertColumn(4,_T("哈夫曼编码"),LVCFMT_LEFT,96);
char ** HC=theApp.m_HuffTree.HufmanCode();
float sum=0.0;
int i;
for(i=0;i<theApp.m_HuffTree.m_nCNum;i++)
sum+=theApp.m_HuffTree.m_pHT[i+1].weight;
for(i=0;i<theApp.m_HuffTree.m_nCNum;i++)
{
float gl=(theApp.m_HuffTree.m_pHT[i+1].weight/sum)*100;
CString baif;
baif.Format("%.2f",gl);
baif+="%";
CString cis;
cis.Format("%d",theApp.m_HuffTree.m_pHT[i+1].weight);
CString code;
code.Format("%s",HC[i+1]);
CString zif;
zif.Format("%c",theApp.m_HuffTree.m_pHT[i+1].data);
m_ctrSCList.InsertItem(i,zif);
m_ctrSCList.SetItemText(i,1,cis);
m_ctrSCList.SetItemText(i,2,baif);
m_ctrSCList.SetItemText(i,3,code);
}
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -