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

📄 setparameter.cpp

📁 连接oracle
💻 CPP
字号:
// SetParameter.cpp : implementation file
//

#include "stdafx.h"
#include "drawcli.h"
#include "SetParameter.h"

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

/////////////////////////////////////////////////////////////////////////////
// CSetParameter dialog


CSetParameter::CSetParameter(CWnd* pParent /*=NULL*/)
	: CDialog(CSetParameter::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSetParameter)
	m_LinkType = FALSE;
	m_owsame = _T("");
	m_oil = _T("");
	m_water = _T("");
	//}}AFX_DATA_INIT
//	m_crBackgColorOil = RGB(255, 0, 255);
//	m_logbrush.lbStyle = BS_SOLID;
//	m_logbrush.lbColor = RGB(255, 0, 0);
//	m_logbrush.lbHatch = HS_HORIZONTAL;	
//	m_brBkgnd.CreateBrushIndirect(&m_logbrush);
	////////////////////////////////////////////////////////////////////////
//	m_bIsCreatingPath = FALSE;
//	m_pCurrentPath = NULL;
}


void CSetParameter::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSetParameter)
	DDX_Check(pDX, IDC_CHECK_LINKTYPE, m_LinkType);
	DDX_Text(pDX, IDC_EDIT_OWSAME, m_owsame);
	DDX_Text(pDX, IDC_EDIT_OIL, m_oil);
	DDX_Text(pDX, IDC_EDIT_WATER, m_water);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSetParameter, CDialog)
	//{{AFX_MSG_MAP(CSetParameter)
	ON_WM_CTLCOLOR()
	ON_BN_CLICKED(IDC_BUTTON_OIL, OnButtonOil)
	ON_BN_CLICKED(IDC_BUTTON_OWSAME, OnButtonOwsame)
	ON_BN_CLICKED(IDC_BUTTON_WATER, OnButtonWater)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSetParameter message handlers

void CSetParameter::OnOK() 
{
	// TODO: Add extra validation here
	if (!UpdateData(true))
	{
		MessageBox("参数保存时出错!","参数",MB_OK|MB_ICONSTOP);
		return;
	}
	
	CDrawApp * App = (CDrawApp *)AfxGetApp();
	//更新系统参数设置
	m_SysParameter.bOnlyLinkOilWater = m_LinkType;
	m_SysParameter.clrOilLayerColor = m_crBackgColorOil;
	m_SysParameter.clrOWSameLayerColor = m_crBackgColorOWSame;
	m_SysParameter.clrWaterLayerColor = m_crBackgColorWater;
	//保存到注册表中
	CString str;
	str.Format("%d",m_LinkType);
	App->WriteProfileString("Setting","onlylinkoilwater",str);
	str.Format("%d",m_crBackgColorOil);
	App->WriteProfileString("Setting","oillayercolor",str);
	str.Format("%d",m_crBackgColorOWSame);
	App->WriteProfileString("Setting","owsamelayercolor",str);
	str.Format("%d",m_crBackgColorWater);
	App->WriteProfileString("Setting","waterlayercolor",str);
	MessageBox("参数保存成功","提示",MB_OK|MB_ICONINFORMATION);
	CDialog::OnOK();
}

BOOL CSetParameter::OnInitDialog() 
{
	CDialog::OnInitDialog();
	m_brBkgnd = CreateSolidBrush(RGB(255,255,255));

	m_crTextColor = RGB(0,0,0);
	
	//得到系统参数
	CDrawApp * App = (CDrawApp *)AfxGetApp();
	CString str;
	str = App->GetProfileString("Setting","oillayercolor","");
	if (str.Compare("")!=0) 
	{
		m_crBackgColorOil = atol(str);
	}
	else
	{
		m_crBackgColorOil = RGB(255,0,0);
	}
	str = App->GetProfileString("Setting","owsamelayercolor","");
	if (str.Compare("")!=0) 
	{
		m_crBackgColorOWSame = atol(str);
	}
	else
	{
		m_crBackgColorOWSame = RGB(255,255,0);
	}
	str = App->GetProfileString("Setting","waterlayercolor","");
	if (str.Compare("")!=0) 
	{
		m_crBackgColorWater = atol(str);
	}
	else
	{
		m_crBackgColorWater = RGB(50,50,255);
	}

	str = App->GetProfileString("Setting","onlylinkoilwater","");
	if (str.Compare("1")==0) 
	{
		//m_SysParameter.nRM = atoi(str);
		m_LinkType = TRUE;
	}
	else
	{
		m_LinkType = FALSE;
	}
	
	UpdateData(false);

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


HBRUSH CSetParameter::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
	//HBRUSH   b=CreateSolidBrush(RGB(255,255,255));
	// TODO: Change any attributes of the DC here
	if(pWnd->GetDlgCtrlID() == IDC_EDIT_OIL)
	{
		//pDC->SetTextColor(m_crTextColor);
		//pDC->SetBkMode(TRANSPARENT);
		pDC->SetBkColor(m_crBackgColorOil);
		return m_brBkgnd;
	}
	else if(pWnd->GetDlgCtrlID() == IDC_EDIT_OWSAME)
	{
		pDC->SetBkColor(m_crBackgColorOWSame);
		return m_brBkgnd;
	}
	else if(pWnd->GetDlgCtrlID() == IDC_EDIT_WATER)
	{
		pDC->SetBkColor(m_crBackgColorWater);
		return m_brBkgnd;
	}
	
		/*
	TCHAR szClassName[64];
	
	::GetClassName(pWnd->GetSafeHwnd(),szClassName,64);
	if(lstrcmpi(szClassName,_T("Edit")) == 0) //是Edit 控件
	{
		DWORD dwStyle = pWnd->GetStyle();
		if((dwStyle & ES_MULTILINE)  == ES_MULTILINE) //多行edit控件
		{
			pDC->SetTextColor(m_crBackgColorOil);
			return hbr;
		}
		else
		{
			HBRUSH   b=CreateSolidBrush(RGB(255,255,255));
			pDC->SetTextColor(RGB(0,0,0));
			//pDC->SetBkMode(TRANSPARENT);
			pDC->SetBkColor(m_crBackgColorOil);
			return (HBRUSH)b;//m_brBkgnd;
		}
	}
	*/
	// TODO: Return a different brush if the default is not desired
	return hbr;
}

void CSetParameter::OnButtonOil() 
{
	// TODO: Add your control notification handler code here
	CColorDialog dlg;
	if (dlg.DoModal() != IDOK)
		return;
	//COLORREF color = dlg.GetColor();
	m_crBackgColorOil = dlg.GetColor();
	Invalidate();
}

void CSetParameter::OnButtonOwsame() 
{
	// TODO: Add your control notification handler code here
	CColorDialog dlg;
	if (dlg.DoModal() != IDOK)
		return;
	//COLORREF color = dlg.GetColor();
	m_crBackgColorOWSame = dlg.GetColor();
	Invalidate();
}

void CSetParameter::OnButtonWater() 
{
	// TODO: Add your control notification handler code here
	CColorDialog dlg;
	if (dlg.DoModal() != IDOK)
		return;
	//COLORREF color = dlg.GetColor();
	m_crBackgColorWater = dlg.GetColor();
	Invalidate();
}

⌨️ 快捷键说明

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