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

📄 dlgregister.cpp

📁 连接MYSQL数据库
💻 CPP
字号:
//author : Jarry
//E-mail : lansingk@online.sh.cn
// DlgRegister.cpp : implementation file
//

#include "stdafx.h"
#include "DlgRegister.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDlgRegister dialog


CDlgRegister::CDlgRegister(CWnd* pParent /*=NULL*/)
	: CDialog(CDlgRegister::IDD, pParent)
{
	//{{AFX_DATA_INIT(CDlgRegister)
	m_strHost = _T("");
	m_strPasswd = _T("");
	m_strServer = _T("");
	m_strUser = _T("");
	m_nPort = 0;
	//}}AFX_DATA_INIT
}


void CDlgRegister::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlgRegister)
	DDX_Text(pDX, IDC_EDT_HOST, m_strHost);
	DDX_Text(pDX, IDC_EDT_PASSWD, m_strPasswd);
	DDX_Text(pDX, IDC_EDT_SERVER, m_strServer);
	DDX_Text(pDX, IDC_EDT_USER, m_strUser);
	DDX_Text(pDX, IDC_EDT_PORT, m_nPort);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDlgRegister, CDialog)
	//{{AFX_MSG_MAP(CDlgRegister)
	ON_BN_CLICKED(IDC_BTN_REGISTER, OnBtnRegister)
	ON_BN_CLICKED(IDC_RAD_STANDARD, OnRadStandard)
	ON_BN_CLICKED(IDC_RAD_TRUST, OnRadTrust)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlgRegister message handlers

void CDlgRegister::OnBtnRegister()
{
	UpdateData(true);

	if (((CButton*)GetDlgItem(IDC_RAD_TRUST))->GetCheck())
		m_bTrust = true;
	else
		m_bTrust = false;

	CDialog::OnOK();
}

void CDlgRegister::OnRadStandard() 
{
	if (((CButton*)GetDlgItem(IDC_RAD_STANDARD))->GetCheck())
	{
		GetDlgItem(IDC_EDT_USER)->EnableWindow(true);
		GetDlgItem(IDC_EDT_PASSWD)->EnableWindow(true);
	}
	else
	{
		GetDlgItem(IDC_EDT_USER)->EnableWindow(false);
		GetDlgItem(IDC_EDT_PASSWD)->EnableWindow(false);
	}
}

void CDlgRegister::OnRadTrust()
{
	if (((CButton*)GetDlgItem(IDC_RAD_STANDARD))->GetCheck())
	{
		GetDlgItem(IDC_EDT_USER)->EnableWindow(true);
		GetDlgItem(IDC_EDT_PASSWD)->EnableWindow(true);
	}
	else
	{
		GetDlgItem(IDC_EDT_USER)->EnableWindow(false);
		GetDlgItem(IDC_EDT_PASSWD)->EnableWindow(false);
	}
}

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

	m_strServer = "localhost";
	m_strHost   = "localhost";
	m_nPort     = MYSQL_PORT;

	((CButton*)GetDlgItem(IDC_RAD_TRUST))->SetCheck(1);
	((CButton*)GetDlgItem(IDC_RAD_STANDARD))->SetCheck(0);
	GetDlgItem(IDC_EDT_USER)->EnableWindow(false);
	GetDlgItem(IDC_EDT_PASSWD)->EnableWindow(false);
	m_strUser   = "root";
	m_strPasswd = "";

	UpdateData(false);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

⌨️ 快捷键说明

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