📄 initestdlg.cpp
字号:
// initestDlg.cpp : implementation file
//
#include "stdafx.h"
#include "INITest.h"
#include "initestDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
CIniTestDlg::CIniTestDlg(CWnd* pParent /*=NULL*/)
: CDialog(CIniTestDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CIniTestDlg)
m_lAge = 0;
m_strName = _T("");
//}}AFX_DATA_INIT
}
void CIniTestDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CIniTestDlg)
DDX_Text(pDX, IDC_EDIT_Age, m_lAge);
DDX_Text(pDX, IDC_EDIT_Name, m_strName);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CIniTestDlg, CDialog)
//{{AFX_MSG_MAP(CIniTestDlg)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CIniTestDlg message handlers
// 测试
#include "ini.h"
void CIniTestDlg::OnButton1()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
CIni Ini("test.ini"); // 打开test.ini文件
//写文件
Ini.Write("index", "name", m_strName.GetBuffer(0));
Ini.Write("index", "年龄", m_lAge);
//保存文件
Ini.Save();
MessageBox("文件 test.ini 保存完毕!");
}
void CIniTestDlg::OnButton2()
{
// TODO: Add your control notification handler code here
CIni Ini("test.ini");
char* name = Ini.ReadText("index", "name");
long age = Ini.ReadInt("index", "年龄");
char str[64];
sprintf(str, "name:%s\n年龄:%d岁", name, age);
MessageBox(str);//显示
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -