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

📄 srbdform.cpp

📁 这是本人两年前兼职为某个公司做的石油钻进设计软件
💻 CPP
字号:
// SrbdForm.cpp : implementation file
//

#include "stdafx.h"
#include "cvenus.h"
#include "SrbdForm.h"
#include "ShwrjCalFuction.h"
#include "Preview.h"
#include "resource.h"

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

/////////////////////////////////////////////////////////////////////////////
// CSrbdForm

IMPLEMENT_DYNCREATE(CSrbdForm, CFormView)

CSrbdForm::CSrbdForm()
	: CFormView(CSrbdForm::IDD)
{
	//{{AFX_DATA_INIT(CSrbdForm)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}

CSrbdForm::~CSrbdForm()
{
}

void CSrbdForm::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSrbdForm)
	DDX_Control(pDX, IDC_SPREAD1, m_SJSR);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSrbdForm, CFormView)
	ON_WM_CONTEXTMENU()
	//{{AFX_MSG_MAP(CSrbdForm)
	ON_WM_CREATE()
	ON_COMMAND(ID_SHWRJ_OPEN, OnShwrjOpen)
	ON_COMMAND(ID_SHWRJ_CALC, OnShwrjCalc)
	ON_COMMAND(ID_SHWRJ_SAVE, OnShwrjSave)
	ON_COMMAND(ID_SHWRJ_PRINTPREVIEW, OnShwrjPrintpreview)
	ON_COMMAND(ID_SHWRJ_PRINT, OnShwrjPrint)
	ON_WM_SIZE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSrbdForm diagnostics

#ifdef _DEBUG
void CSrbdForm::AssertValid() const
{
	CFormView::AssertValid();
}

void CSrbdForm::Dump(CDumpContext& dc) const
{
	CFormView::Dump(dc);
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CSrbdForm message handlers

BEGIN_EVENTSINK_MAP(CSrbdForm, CFormView)
    //{{AFX_EVENTSINK_MAP(CSrbdForm)
	ON_EVENT(CSrbdForm, IDC_SPREAD1, 4 /* Change */, OnChangeSpread1, VTS_I4 VTS_I4)
	//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()

void CSrbdForm::OnChangeSpread1(long Col, long Row) 
{
	// TODO: Add your control notification handler code here
      CString Temp1;
	  m_SJSR.SetCol(5);
	  m_SJSR.SetRow(3);   
	  Temp1=m_SJSR.GetText();
	  if(Temp1=="甲醇"||Temp1=="乙醇"||Temp1=="乙二醇")
	  {
        m_SJSR.SetCol(3);
	    m_SJSR.SetRow(4); 
		m_SJSR.SetText("0");
        m_SJSR.SetCol(4);
	    m_SJSR.SetRow(4); 
		m_SJSR.SetText("99.99");
	  }
	  if(Temp1=="异丙醇")
	  {
        m_SJSR.SetCol(3);
	    m_SJSR.SetRow(4); 
		m_SJSR.SetText("0");
        m_SJSR.SetCol(4);
	    m_SJSR.SetRow(4); 
		m_SJSR.SetText("23.99");
	  }
	  if(Temp1=="丙二醇")
	  {
        m_SJSR.SetCol(3);
	    m_SJSR.SetRow(4); 
		m_SJSR.SetText("0");
        m_SJSR.SetCol(4);
	    m_SJSR.SetRow(4); 
		m_SJSR.SetText("15.99");
	  }
	  if(Temp1=="氯化钠")
	  {
        m_SJSR.SetCol(3);
	    m_SJSR.SetRow(4); 
		m_SJSR.SetText("0");
        m_SJSR.SetCol(4);
	    m_SJSR.SetRow(4); 
		m_SJSR.SetText("22.99");
	  }
	  if(Temp1=="氯化钙")
	  {
        m_SJSR.SetCol(3);
	    m_SJSR.SetRow(4); 
		m_SJSR.SetText("0");
        m_SJSR.SetCol(4);
	    m_SJSR.SetRow(4); 
		m_SJSR.SetText("31.99");
	  }	
	
}

int CSrbdForm::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CFormView::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	// TODO: Add your specialized creation code here
	GetParentFrame()->SetWindowText(_T("冰点下降法预测生成温度降"));
	
	return 0;
}

void CSrbdForm::OnInitialUpdate() 
{
	CFormView::OnInitialUpdate();
	
	// TODO: Add your specialized code here and/or call the base class
/*	int i,j;

	m_SJSR.SetMaxRows(8);
	m_SJSR.SetMaxCols(5);
    
	m_SJSR.SetDisplayColHeaders(FALSE);//取消表头
	m_SJSR.SetDisplayRowHeaders(FALSE);//取消表头
    m_SJSR.SetGridShowHoriz(FALSE);//不显示网格线
	m_SJSR.SetGridShowVert(FALSE);//不显示网格线

	m_SJSR.SetRow(-1);
	m_SJSR.SetCol(-1);
	m_SJSR.SetAction(3);
	m_SJSR.SetFontName("宋体");
	m_SJSR.SetFontSize(12);

	m_SJSR.SetCol(3);
	m_SJSR.SetRow(1);
	m_SJSR.SetColWidth(3,12);
	m_SJSR.SetRowHeight(1,15);
	m_SJSR.SetValue("参数输入");

   //设置表格不可编辑
	for(i=1;i<=5;i++)
	   for(j=1;j<=8;j++)
	   {
			m_SJSR.SetCol(i);
			m_SJSR.SetRow(j);
		    m_SJSR.SetCellType(5);
	   }
	
   // 设置单元格线样式
   for(i=1;i<=5;i++)
	   for(j=2;j<=4;j++)
	   {
			m_SJSR.SetCol(i);
			m_SJSR.SetRow(j);
			m_SJSR.SetCellBorderType(16);//单元格为实框
			m_SJSR.SetCellBorderStyle(1);//实线
			m_SJSR.SetCellBorderColor(RGB(0,0,0));//单元格边框颜色
			m_SJSR.SetAction(16);//激活
	   }

	
	m_SJSR.SetCol(1);
	m_SJSR.SetColWidth(1,22);
	m_SJSR.SetRowHeight(2,20);

	m_SJSR.SetRow(2);
	m_SJSR.SetValue("参数名称");    
	m_SJSR.SetRow(3);
	m_SJSR.SetText("抑制剂种类");
	m_SJSR.SetRow(4);
	m_SJSR.SetText("抑制剂溶液重量浓度");

  	m_SJSR.SetCol(2);
	m_SJSR.SetColWidth(2,15);
	m_SJSR.SetRowHeight(2,20);

	m_SJSR.SetRow(2);
	m_SJSR.SetValue("单位");
	m_SJSR.SetRow(3);
	m_SJSR.SetText(" ");
	m_SJSR.SetRow(4);
	m_SJSR.SetText("%");


	m_SJSR.SetCol(3);
	m_SJSR.SetColWidth(3,8);

	m_SJSR.SetRow(2);
	m_SJSR.SetValue("最小值");
	m_SJSR.SetRow(4);
	m_SJSR.SetText(" ");
	m_SJSR.SetRow(4);
	m_SJSR.SetText("0");

	m_SJSR.SetCol(4);
	m_SJSR.SetColWidth(4,8);

	m_SJSR.SetRow(2);
	m_SJSR.SetValue("最大值");
	m_SJSR.SetRow(3);
	m_SJSR.SetText(" ");
	m_SJSR.SetRow(4);
	m_SJSR.SetText("100");

	m_SJSR.SetCol(5);
	m_SJSR.SetColWidth(5,12);

	m_SJSR.SetRow(2);
	m_SJSR.SetValue("参数值");
    for(i=3;i<=5;i++)
	{
		m_SJSR.SetRow(i);
		m_SJSR.SetCellType(2);
		m_SJSR.SetTypeFloatDecimalPlaces(5);
		m_SJSR.SetTypeFloatMin(0);
		m_SJSR.SetTypeFloatMax(99999);
	}	
	m_SJSR.SetCol(5);
	m_SJSR.SetRow(3);
	m_SJSR.SetCellType(8);
	m_SJSR.SetTypeComboBoxList("甲醇\t乙醇\t乙二醇\t异丙醇\t丙二醇\t氯化钠\t氯化钙");
	m_SJSR.SetCol(3);
	m_SJSR.SetRow(6);
	m_SJSR.SetColWidth(3,10);
	m_SJSR.SetValue("计算结果");

	m_SJSR.SetCol(2);
	m_SJSR.SetRow(7);
	m_SJSR.SetColWidth(2,10);
	m_SJSR.SetValue("温度降");

	m_SJSR.SetCol(4);
	m_SJSR.SetRow(7);
	m_SJSR.SetCellType(5);
	m_SJSR.SetValue("K");

	m_SJSR.SetCol(2);
	m_SJSR.SetRow(7);
    m_SJSR.SetCol2(2);
	m_SJSR.SetRow2(7);
	m_SJSR.SetBlockMode(TRUE);
	m_SJSR.SetCellBorderType(16);
	m_SJSR.SetCellBorderStyle(1);
	m_SJSR.SetCellBorderColor(RGB(0,0,0));
	m_SJSR.SetAction(16);
    m_SJSR.SetBlockMode(FALSE);

	m_SJSR.SetCol(3);
	m_SJSR.SetRow(7);
    m_SJSR.SetCol2(3);
	m_SJSR.SetRow2(7);
	m_SJSR.SetBlockMode(TRUE);
	m_SJSR.SetCellBorderType(16);
	m_SJSR.SetCellBorderStyle(1);
	m_SJSR.SetCellBorderColor(RGB(0,0,0));
	m_SJSR.SetAction(16);
    m_SJSR.SetBlockMode(FALSE);

	m_SJSR.SetCol(4);
	m_SJSR.SetRow(7);
    m_SJSR.SetCol2(4);
	m_SJSR.SetRow2(7);
	m_SJSR.SetBlockMode(TRUE);
	m_SJSR.SetCellBorderType(16);
	m_SJSR.SetCellBorderStyle(1);
	m_SJSR.SetCellBorderColor(RGB(0,0,0));
	m_SJSR.SetAction(16);
    m_SJSR.SetBlockMode(FALSE);

    m_SJSR.SetRow(8);
    m_SJSR.SetValue("  ");		
*/	
}

void CSrbdForm::OnShwrjOpen() 
{
	CString fileDialogFilter1="冰点下降法预测生成温度降(*.BDWD)|*.BDWD||";
	const char fileDialogExt1[] = "BDWD";
	CFileDialog fileDialog1(TRUE,fileDialogExt1,NULL,OFN_FILEMUSTEXIST, fileDialogFilter1);
    if(fileDialog1.DoModal()==IDOK)
	{
	    CString filename1=fileDialog1.GetPathName();//+fileDialog.GetFileName();		
	    m_SJSR.LoadFromFile(filename1);		
	}
    UpdateData(FALSE);		
	
}

void CSrbdForm::OnShwrjCalc() 
{
	//Dim msg
	 //t——水化物生成温度降,K
	 //t1——抑制剂冰点下降值
	 //w——抑制剂溶液重量浓度
	 //kk——抑制剂种类
	 //a类——甲醇
	 //B类——乙醇
	 //C类——乙二醇
	 //D类——异丙醇
	 //E类——丙二醇
	 //F类——氯化钠
	 //G类——氯化钙
	 CString Temp1,Temp2;
     double zdz,zxz;
	 char Temp3[30];
     double w;
	 int kk;
	 double t, T1;
     m_SJSR.SetCol(5);
     m_SJSR.SetRow(4);   
     Temp1=m_SJSR.GetText();
     m_SJSR.SetRow(3);   
     Temp2=m_SJSR.GetText(); 
	 if(Temp2=="甲醇")
		 kk=1;
	 if(Temp2=="乙醇")
		 kk=2;
	 if(Temp2=="乙二醇")
		 kk=3;
	 if(Temp2=="异丙醇")
		 kk=4;
	 if(Temp2=="丙二醇")
		 kk=5;
	 if(Temp2=="氯化钠")
		 kk=6;
	 if(Temp2=="氯化钙")
		 kk=7;
	 w = atof(Temp1);
//取参数范围
     m_SJSR.SetCol(3);
     m_SJSR.SetRow(4);   
     zxz=atof(m_SJSR.GetText());
     m_SJSR.SetCol(4);
     m_SJSR.SetRow(4);   
     zdz=atof(m_SJSR.GetText());
if(w>zxz&&w<=zdz)
{     
	 switch(kk)
	 {
	   case 1:
		  if (w > 0 && w <= 68)
		  {
			  T1 = -0.419695 + 0.683433 * w + 0.0022054 * pow(w,2) + 0.000122945 * pow(w,3);
			  t = 273.15 + 0.665 * T1;
		  }
		  else if (w > 68 && w <= 82.9)
		  {
			  T1 = 246.7026 - 2.5274 * w - 0.0128865 * pow(w,2) + 0.000162995 * pow(w,3) + 0.00000176 * pow(w,4);
			  t = 273.15 + 0.665 * T1;
		  }
		  else if (w > 82.9 && w < 100)
		  {
			  T1 = 251.4294 - 1.542866 * w;
			  t = 273.15 + 0.665 * T1;
		  }
		  break;
		case 2:
		  if (w > 0 && w <= 93.5)
		  {
			  T1 = 19.4106 - 0.277068 * w + 0.03656 * pow(w,2) - 0.0006934 * pow(w,3) + 0.00000441 * pow(w,4);
			  t = 273.15 + 0.665 * T1;
		  }
		  else if (w > 93.5 && w < 100)
		  {
			  T1 = 225.5872 - 1.15116 * w;
			  t = 273.15 + 0.665 * T1;
		  }
		  break;
	  case 3:
		  if (w > 0 && w <= 56)
		  {
			 T1 = 0.05218 + 0.28532 * w + 0.0050388 * pow(w,2) + 0.00006043 * pow(w,3) + 0.0000001918 * pow(w,4);
			 t = 273.15 + 0.665 * T1;
		  }
		  else if (w > 56 && w < 100)   
		  {
			  T1 = 121.4078 + 0.2892 * w + 0.01492 * pow(w,2) + 0.000069 * pow(w,3) + 0.0000008086 * pow(w,4);
			  t = 273.15 + 0.665 * T1;
		  }
		  break;
		case 4:
		  if (w > 0 && w <= 24)
		  {
			 T1 = 0.0007794 + 0.29915 * w + 0.00241 * pow(w,2) + 0.000342 * pow(w,3) + 0.000007198 * pow(w,4);
			 t = 273.15 + 0.665 * T1;
		  }
		  else      AfxMessageBox( "超过应用浓度范围");
		  break;
		case 5:
		  if (w > 0 && w < 16)
		  {
			  T1 = 8.383 + 0.2413 * w + 0.00452 * pow(w,2) + 0.000375 * pow(w,3) + 0.000029795 * pow(w,4);
			  t = 273.15 + 0.665 * T1;
		  }
		  else      AfxMessageBox( "超过应用浓度范围");
		  break;
		case 6:
		  if (w > 0 && w < 23)
		  {
			 T1 = 0.009187 + 0.57744 * w + 0.00456 * pow(w,2) + 0.0002637 * pow(w,3) + 0.000005979 * pow(w,4);
			 t = 273.15 + 0.665 * T1;
		  }
		  else      AfxMessageBox( "超过应用浓度范围");
		  break;
		case 7:
		  if (w > 0 && w < 32)
		  {
			 T1 = 0.4663 + 0.0576 * w + 0.07004 * pow(w,2) + 0.002637 * pow(w,3) + 0.0000587 * pow(w,4);
			 t = 273.15 + 0.665 * T1;//单位K
		  }
		  else      AfxMessageBox( "超过应用浓度范围");
		  break;
		  default:      AfxMessageBox ("抑制剂选用不当");
		}
  //输出结果
   gcvt(t,7,Temp3);
   m_SJSR.SetCol(2);
   m_SJSR.SetRow(7);
   m_SJSR.SetValue(Temp3);
}
else
{
   AfxMessageBox("抑制剂溶液重量浓度输入数据非法");
}
	
}

void CSrbdForm::OnShwrjSave() 
{
	UpdateData(TRUE);
	CString fileDialogFilter1="冰点下降法预测生成温度降(*.BDWD)|*.BDWD||";
	const char fileDialogExt1[] = "BDWD";
	CFileDialog fileDialog1(FALSE,fileDialogExt1,NULL,OFN_FILEMUSTEXIST, fileDialogFilter1);
    if(fileDialog1.DoModal()==IDOK)
	{
	    CString filename1=fileDialog1.GetPathName();//+fileDialog.GetFileName();		
	    m_SJSR.SaveToFile(filename1,FALSE);		
	}	
	
}

void CSrbdForm::OnShwrjPrintpreview() 
{
	// TODO: Add your command handler code here
	CPreview dlg(&m_SJSR);
	dlg.DoModal();
	
}

void CSrbdForm::OnShwrjPrint() 
{
    m_SJSR.SetAction(13);		
	
}

void CSrbdForm::OnContextMenu(CWnd*, CPoint point)
{
	// CG: This block was added by the Pop-up Menu component	{		if (point.x == -1 && point.y == -1){			//keystroke invocation			CRect rect;			GetClientRect(rect);			ClientToScreen(rect);			point = rect.TopLeft();			point.Offset(5, 5);		}		CMenu menu;		VERIFY(menu.LoadMenu(IDR_POPUP_SHWRJ));		CMenu* pPopup = menu.GetSubMenu(0);		ASSERT(pPopup != NULL);		CWnd* pWndPopupOwner = this;//		while (pWndPopupOwner->GetStyle() & WS_CHILD)//			pWndPopupOwner = pWndPopupOwner->GetParent();		pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y,			pWndPopupOwner);	}
}

void CSrbdForm::OnSize(UINT nType, int cx, int cy) 
{
	CFormView::OnSize(nType, cx, cy);
	
	// TODO: Add your message handler code here
	if(m_SJSR.m_hWnd != NULL)
	{
		CRect rc;	
		GetClientRect(&rc);
		m_SJSR.SetWindowPos(NULL, rc.left, rc.top, rc.Width(), rc.Height(), NULL);
	}
	
}

⌨️ 快捷键说明

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