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

📄 syssetdlg.cpp

📁 本程序是采用VC++和Mysql编写的一款油量换算软件
💻 CPP
字号:
// SysSetDlg.cpp : implementation file
//

#include "stdafx.h"
#include "OilTrans.h"
#include "SysSetDlg.h"
#include "OilTransDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CSysSetDlg dialog


CSysSetDlg::CSysSetDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CSysSetDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSysSetDlg)
	m_bSave = FALSE;
	m_bSR = FALSE;
	m_bTank = FALSE;
	m_bVolume = FALSE;
	m_bDB = FALSE;
	//}}AFX_DATA_INIT
	nDBN =0;
}


void CSysSetDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSysSetDlg)
	DDX_Control(pDX, IDC_CMB_DBNAME, m_cCmbDB);
	DDX_Check(pDX, IDC_CCK_SAVE, m_bSave);
	DDX_Check(pDX, IDC_CCK_SR, m_bSR);
	DDX_Check(pDX, IDC_CCK_Height, m_bTank);
	DDX_Check(pDX, IDC_CCK_V, m_bVolume);
	DDX_Check(pDX, IDC_CHECK_DB, m_bDB);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSysSetDlg, CDialog)
	//{{AFX_MSG_MAP(CSysSetDlg)
	ON_BN_CLICKED(IDC_BTN_OOK, OnBtnOok)
	ON_BN_CLICKED(IDC_BTN_OCANCEL, OnBtnOcancel)
	ON_BN_CLICKED(IDC_BTN_SYSCANCEL, OnBtnSyscancel)
	ON_BN_CLICKED(IDC_BTN_SYSOK, OnBtnSysok)
	ON_BN_CLICKED(IDC_CHECK_DB, OnCheckDb)
	ON_BN_CLICKED(IDC_CCK_Height, OnCckTank)
	ON_BN_CLICKED(IDC_CCK_V, OnCckV)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSysSetDlg message handlers

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

void CSysSetDlg::OnBtnOok() 
{
	// TODO: Add your control notification handler code here
		UpdateData(TRUE);
	if(m_bVolume)
		::SendMessage(hWnd, WM_OT_TV, (WPARAM)('v'), (LPARAM)0);
	else
		::SendMessage(hWnd, WM_OT_TV, (WPARAM)('t'), (LPARAM)-1);
	if(m_bSave)
		::SendMessage(hWnd, WM_OT_SAVE, (WPARAM)('s'), (LPARAM)0);
	else
		::SendMessage(hWnd, WM_OT_SAVE, (WPARAM)('n'), (LPARAM)-1);
	

	UpdateData(FALSE);
}

void CSysSetDlg::OnBtnOcancel() 
{
	// TODO: Add your control notification handler code here
	
}

void CSysSetDlg::OnBtnSyscancel() 
{
	// TODO: Add your control notification handler code here
	
}

void CSysSetDlg::OnBtnSysok() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	if(m_bDB)
	{
		int nDB = m_cCmbDB.GetCurSel();
		if(nDB == 0)
		{
			AfxMessageBox("请选择数据库!");
			return;
		}
        ::SendMessage(hWnd, WM_OT_DB, (WPARAM)('s'), (LPARAM)0);
		::SendMessage(hWnd, WM_OT_DBN, (WPARAM)('s'), (LPARAM)nDB);
	}
	else
	{
		::SendMessage(hWnd, WM_OT_DB, (WPARAM)('s'), (LPARAM)-1);
		::SendMessage(hWnd, WM_OT_DBN, (WPARAM)('s'), (LPARAM)0);
	}
	if(m_bSR)
	{
		::SendMessage(hWnd, WM_OT_SR, (WPARAM)('s'), (LPARAM)0);
	}
	else
		::SendMessage(hWnd, WM_OT_SR, (WPARAM)('n'), (LPARAM)-1);
	UpdateData(FALSE);
}

void CSysSetDlg::InitDB(BOOL b)
{

	UpdateData(TRUE);
	if(b)
	{
		m_cCmbDB.AddString("No DB");
		m_cCmbDB.AddString("MySql");
		m_cCmbDB.AddString("Access");
		m_cCmbDB.AddString("Sql Sever");
	}
    if(m_bDB){
		m_cCmbDB.SetCurSel(1);
	}
	else
	{
		m_cCmbDB.SetCurSel(0);
	}
	m_cCmbDB.EnableWindow(m_bDB);
    UpdateData(FALSE);
}

void CSysSetDlg::OnCheckDb() 
{
	// TODO: Add your control notification handler code here
    m_cCmbDB.EnableWindow(TRUE);
	InitDB(FALSE);

}

void CSysSetDlg::OnCckTank() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	m_bVolume = ~m_bTank;
	UpdateData(FALSE);
}

void CSysSetDlg::OnCckV() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	m_bTank = ~m_bVolume;
	UpdateData(FALSE);
}



void CSysSetDlg::SetWnd(HWND wnd)
{
    hWnd =wnd;
}


void CSysSetDlg::SetSR(BOOL b)
{
   m_bSR = b;
}

void CSysSetDlg::SetSave(BOOL b)
{
    m_bSave =b;
}

void CSysSetDlg::SetTank(BOOL b)
{
    m_bTank = b;
	if(b)
	    m_bVolume =FALSE;
	else
		m_bVolume =TRUE;
	  
}

void CSysSetDlg::SetDB(BOOL b)
{
    m_bDB =b;
}

void CSysSetDlg::SetDBN(int nDBN)
{
   nDBN = nDBN;
}

⌨️ 快捷键说明

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