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

📄 coefdefdlg.cpp

📁 数据结构链表的演示程序
💻 CPP
字号:
// CoefDefDlg.cpp : implementation file
//

#include "stdafx.h"
#include "LandSoft.h"
#include "CoefDefDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CCoefDefDlg dialog


CCoefDefDlg::CCoefDefDlg(CWnd* pParent,CArray<Types,Types>& blocks,
						 BOOL everdefine,CArray<double,double>& coefs)
	: CDialog(CCoefDefDlg::IDD, pParent)
{
	m_ControlsNum=blocks.GetSize();
	m_Controls.SetSize(m_ControlsNum,-1);
	m_BlockTypes.Copy(blocks);
	m_bEverDefine=everdefine;
	m_Coefs.SetSize(m_ControlsNum*4,-1);
	m_Coefs.Copy(coefs);
}


void CCoefDefDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CCoefDefDlg)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CCoefDefDlg, CDialog)
	//{{AFX_MSG_MAP(CCoefDefDlg)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CCoefDefDlg message handlers

BOOL CCoefDefDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	for(int i=0;i<m_ControlsNum;i++)		// 逐行绘制控件
	{
		CString id;
		id.Format("%d",i+1);
		m_Controls[i].m_ID.Create(id,WS_CHILD|WS_VISIBLE|SS_LEFT,
			CRect(30,73+30*i,50,96+30*i),this,MYID2+7*i);
		m_Controls[i].m_Name.Create(m_BlockTypes[i].Name,WS_CHILD|WS_VISIBLE|SS_LEFT,
			CRect(70,73+30*i,137,96+30*i),this,MYID2+7*i+1);
		
		BYTE colorindex=m_BlockTypes[i].Val;
		CString value;
		value.Format("%d",colorindex);
		m_Controls[i].m_Value.Create(value,WS_CHILD|WS_VISIBLE|SS_CENTER,
			CRect(150,73+30*i,180,96+30*i),this,MYID2+7*i+2);

		m_Controls[i].m_City.Create(ES_CENTER|WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_BORDER,
			CRect(180+20,71+30*i,180+100,96+30*i),this,MYID2+7*i+3);
		m_Controls[i].m_Jamming.Create(ES_CENTER|WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_BORDER,
			CRect(180+120,71+30*i,180+200,96+30*i),this,MYID2+7*i+4);
		m_Controls[i].m_Plant.Create(ES_CENTER|WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_BORDER,
			CRect(180+220,71+30*i,180+300,96+30*i),this,MYID2+7*i+5);
		m_Controls[i].m_Risk.Create(ES_CENTER|WS_CHILD|WS_VISIBLE|WS_TABSTOP|WS_BORDER,
			CRect(180+320,71+30*i,180+400,96+30*i),this,MYID2+7*i+6);
		
	}
	
	if(m_bEverDefine)
	{
		CString tmpstr;
		for (int j=0;j<m_ControlsNum;j++)
		{
			tmpstr.Format("%f",m_Coefs[4*j]);
			m_Controls[j].m_City.SetWindowText(tmpstr);
			tmpstr.Format("%f",m_Coefs[4*j+1]);
			m_Controls[j].m_Jamming.SetWindowText(tmpstr);
			tmpstr.Format("%f",m_Coefs[4*j+2]);
			m_Controls[j].m_Plant.SetWindowText(tmpstr);
			tmpstr.Format("%f",m_Coefs[4*j+3]);
			m_Controls[j].m_Risk.SetWindowText(tmpstr);
		}
	}

	m_OK.Create(_T("确定"),WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|WS_TABSTOP,
		CRect(150,90+30*i,260,118+30*i),this,IDOK);
	m_Cancel.Create(_T("取消"),WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|WS_TABSTOP,
		CRect(340,90+30*i,450,118+30*i),this,IDCANCEL);

	SetWindowPos(NULL,10,50,610,35+30*i+125,SWP_NOACTIVATE);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CCoefDefDlg::OnOK()		// 更新与控件相连的值
{
	for(int i=0;i<m_ControlsNum;i++)
	{
		CString tmpstr;
		m_Controls[i].m_City.GetWindowText(tmpstr);
		m_Coefs[i*4]=atof(tmpstr);
		m_Controls[i].m_Jamming.GetWindowText(tmpstr);
		m_Coefs[i*4+1]=atof(tmpstr);
		m_Controls[i].m_Plant.GetWindowText(tmpstr);
		m_Coefs[i*4+2]=atof(tmpstr);
		m_Controls[i].m_Risk.GetWindowText(tmpstr);
		m_Coefs[i*4+3]=atof(tmpstr);
	}

	CDialog::OnOK();
}

⌨️ 快捷键说明

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