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

📄 算号器dlg.cpp

📁 用VC+SQL实现的物流管理系统 “RxMediaPlayer” 文件夹中存放《物流综合管理系统》中《媒体播放平台》源程序 “数据库设置”文件夹中存放《物流综合管理系统》辅助工具《数据库设置》源程
💻 CPP
字号:
// 算号器Dlg.cpp : implementation file
//

#include "stdafx.h"
#include "算号器.h"
#include "算号器Dlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CMyDlg dialog

CMyDlg::CMyDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CMyDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CMyDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CMyDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMyDlg)
	DDX_Control(pDX, IDC_EDTUSERNAME, m_EdtUserName);
	DDX_Control(pDX, IDC_EDTREGCODE, m_EdtRegCode);
	DDX_Control(pDX, IDC_EDTPATH, m_EdtPath);
	DDX_Control(pDX, IDC_EDTMICCODE, m_EdtMicCode);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
	//{{AFX_MSG_MAP(CMyDlg)
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_BN_CLICKED(IDC_BUTGET, OnButget)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMyDlg message handlers

BOOL CMyDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here
	
	return TRUE;  // return TRUE  unless you set the focus to a control
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CMyDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CMyDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

void CMyDlg::OnOK() 
{
	// TODO: Add extra validation here
	
	CDialog::OnOK();
}

void CMyDlg::OnCancel() 
{
	// TODO: Add extra cleanup here
	
	CDialog::OnCancel();
}

void CMyDlg::OnButton1() 
{
	CFileDialog file(true);
	file.DoModal();
	this->m_EdtPath.SetWindowText(file.GetPathName());
}

void CMyDlg::OnButget() 
{
	CString sPath;

	m_EdtPath.GetWindowText(sPath);
	CFile file( sPath, CFile::modeRead );  
	int nLength=file.GetLength();
	char * pText=new char[nLength];

	file.Read(pText,nLength);
	file.Close();
	CString sText;
	sText.Format("%s",pText);
	sText=sText.Left(nLength);
	
	int nPosition=sText.Find("~");
	if(nPosition==-1)
	{
		MessageBox("注册文件不正确或已经损坏,请重新生成!","系统提示",MB_OK|MB_ICONSTOP);
		return;
	}
	CString sName,sCode;
	sName=sText.Left(nPosition);
	sCode=sText.Mid(nPosition+1);
	int nCode=atoi(sCode)^1234567890123;
	sCode.Format("%d",nCode);
	m_EdtUserName.SetWindowText(sName);
	m_EdtMicCode.SetWindowText(sCode);
	//计算序列号
	char * cNameCode=sName.GetBuffer(sName.GetLength());
	DWORD dNameCode=*cNameCode;
	sCode.Format("%d",atoi(sCode)^dNameCode);
	for(int i=0;i<sCode.GetLength();i++)
	{
		if((i+1)%4==0)
			sCode.Insert(i,"-");
	}
	this->m_EdtRegCode.SetWindowText(sCode);
}

⌨️ 快捷键说明

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