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

📄 setpassword.cpp

📁 visual c++ 实例编程
💻 CPP
字号:
// setpassword.cpp : implementation file
//

#include "stdafx.h"
#include "作品.h"
#include "setpassword.h"

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

/////////////////////////////////////////////////////////////////////////////
// Csetpassword dialog


Csetpassword::Csetpassword(CWnd* pParent /*=NULL*/)
	: CDialog(Csetpassword::IDD, pParent)
{
	//{{AFX_DATA_INIT(Csetpassword)
	m_first = _T("");
	m_second = _T("");
	//}}AFX_DATA_INIT
}


void Csetpassword::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(Csetpassword)
	DDX_Text(pDX, IDC_EDIT_first, m_first);
	DDX_Text(pDX, IDC_EDIT_second, m_second);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(Csetpassword, CDialog)
	//{{AFX_MSG_MAP(Csetpassword)
	ON_WM_CREATE()
	ON_WM_CLOSE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// Csetpassword message handlers

void Csetpassword::OnOK() 
{
	// TODO: Add extra validation here
	UpdateData(true);
	if(m_first!=m_second)
	{
		if(m_first!=m_second)
		{
			AfxMessageBox("两次输入的密码不相符合!");
			m_first=m_second="";
		}
		UpdateData(false);
	}
	else
	{
		passwordfile.Open("std.dat",CFile::modeCreate|CFile::modeWrite|CFile::typeText,NULL);
		if(m_first!="")
		{
			passwordfile.WriteString(m_first);
			passwordfile.Close();
		}
		else 
		{
			passwordfile.Close();
			CFile::Remove("std.dat");
		}
		CDialog::OnOK();
	}
}

int Csetpassword::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CDialog::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	// TODO: Add your specialized creation code here
	return 0;
}

BOOL Csetpassword::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void Csetpassword::OnClose() 
{
	// TODO: Add your message handler code here and/or call default
	CDialog::OnClose();
}

void Csetpassword::OnCancel() 
{	
	CDialog::OnCancel();
}

⌨️ 快捷键说明

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