inputdlg.cpp

来自「哈夫曼编码解码演示程序」· C++ 代码 · 共 63 行

CPP
63
字号
// InputDlg.cpp : implementation file
//

#include "stdafx.h"
#include "Huffman.h"
#include "InputDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CInputDlg dialog


CInputDlg::CInputDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CInputDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CInputDlg)
	m_sInput = _T("");
	//}}AFX_DATA_INIT
}


void CInputDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CInputDlg)
	DDX_Text(pDX, IDC_DATA, m_sInput);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CInputDlg, CDialog)
	//{{AFX_MSG_MAP(CInputDlg)
	ON_BN_CLICKED(IDC_RANDOM, OnRandom)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CInputDlg message handlers

void CInputDlg::OnRandom() 
{
	m_sInput.Empty();
	UpdateData(FALSE);
	srand((unsigned)time(NULL));
	int num=4+rand()%7;
	CString str;
	int n=0;
    for(int i=0;i<num;i++)
	{		
		srand((unsigned)n);
		n=rand()%100;
		str.Format("%d,",n);
		m_sInput+=str;
	}
	m_sInput.TrimRight(',');
	UpdateData(FALSE);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?