⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getdatadlg.cpp

📁 1 可执行程序TestLexicon.exe必须与数据库文件在同一个目录下 2 数据库文件名为: lexicon.mdb
💻 CPP
字号:
// GetDataDlg.cpp : implementation file
//

#include "stdafx.h"
#include "TestLexicon.h"
#include "GetDataDlg.h"
#include "math.h"
#include "stdlib.h"

#include "io.h"          // 包含 _findfirst(), _findnext()函数原型
#include "direct.h"      // 包含 _chdir()函数原型
#include "errno.h"       // 包含系统变量errno

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

/////////////////////////////////////////////////////////////////////////////
// CGetDataDlg dialog

CGetDataDlg::CGetDataDlg(const char * Prompt, CWnd* pParent /*=NULL*/)
	: CDialog(CGetDataDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CGetDataDlg)
	m_Input_Data = _T("");
	//}}AFX_DATA_INIT
	PromptStr = Prompt;
}


void CGetDataDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CGetDataDlg)
	DDX_Text(pDX, IDC_INPUT_DATA, m_Input_Data);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CGetDataDlg, CDialog)
	//{{AFX_MSG_MAP(CGetDataDlg)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CGetDataDlg message handlers

BOOL CGetDataDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	SetWindowText(PromptStr);  // 初始化函数将提示信息设置为对话框标题
	// TODO: Add extra initialization here
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}



BOOL GetData(const char * Prompt, CString & Data)
{ // input a string
	CGetDataDlg dlg(Prompt);  // call dlg class function
	if(dlg.DoModal()!= IDOK) return FALSE; // if user select CANCEL
	Data=dlg.m_Input_Data; // 给形参赋值,原书上用dlg.DataString读取数据似乎不行
	return TRUE;
}

BOOL GetData(const char * Prompt, int & Data)
{ // input an int
	CGetDataDlg dlg(Prompt);  // call dlg function
	if(dlg.DoModal()!= IDOK) return FALSE; // if user select CANCEL
	dlg.m_Input_Data.TrimLeft();
	dlg.m_Input_Data.TrimRight();

	Data=atoi((const char *)(dlg.m_Input_Data)); // 转换为整数
	return TRUE;
}

BOOL GetData(const char * Prompt, double & Data)
{ // input a real number
	CGetDataDlg dlg(Prompt);  // call dlg function
	if(dlg.DoModal()!= IDOK) return FALSE; // if user select CANCEL
	dlg.m_Input_Data.TrimLeft();
	dlg.m_Input_Data.TrimRight();
	Data=atof((const char *)(dlg.m_Input_Data)); // 转换为实数
	return TRUE;
}

⌨️ 快捷键说明

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