dialognewproject.cpp
来自「这是本人两年前兼职为某个公司做的石油钻进设计软件」· C++ 代码 · 共 198 行
CPP
198 行
// DialogNewProject.cpp : implementation file
//
#include "stdafx.h"
#include "CVenus.h"
#include "DialogNewProject.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDialogNewProject dialog
extern CCVenusApp theApp;
CDialogNewProject::CDialogNewProject(CWnd* pParent /*=NULL*/)
: CDialog(CDialogNewProject::IDD, pParent)
{
//{{AFX_DATA_INIT(CDialogNewProject)
m_cstrAuditing = _T("");
m_cstrCon = _T("");
m_cstrDate = _T("");
m_cstrOilFieldName = _T("");
m_cstrSDTPath = _T("");
m_cstrWellName = _T("");
m_iGasWell = -1;
m_iOilWell = 0;
m_cstrProjectPath = _T("");
m_cstrStylist = _T("");
//}}AFX_DATA_INIT
m_bWellState = TRUE; //TRUE:油井
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CDialogNewProject::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDialogNewProject)
DDX_Control(pDX, IDC_BUTTON_NEWPROJECT_BROWSE, m_ctrlProjectPath);
DDX_Text(pDX, IDC_EDIT_AUDITING, m_cstrAuditing);
DDV_MaxChars(pDX, m_cstrAuditing, 20);
DDX_Text(pDX, IDC_EDIT_CONCORP, m_cstrCon);
DDV_MaxChars(pDX, m_cstrCon, 40);
DDX_Text(pDX, IDC_EDIT_DATE, m_cstrDate);
DDV_MaxChars(pDX, m_cstrDate, 20);
DDX_Text(pDX, IDC_EDIT_OILFIELDNAME, m_cstrOilFieldName);
DDV_MaxChars(pDX, m_cstrOilFieldName, 40);
DDX_Text(pDX, IDC_EDIT_SDTPATH, m_cstrSDTPath);
DDX_Text(pDX, IDC_EDIT_WELLNAME, m_cstrWellName);
DDV_MaxChars(pDX, m_cstrWellName, 40);
DDX_Radio(pDX, IDC_RADIO_GASWELL, m_iGasWell);
DDX_Radio(pDX, IDC_RADIO_OILWELL, m_iOilWell);
DDX_Text(pDX, IDC_EDIT_PROJECTPATH, m_cstrProjectPath);
DDX_Text(pDX, IDC_EDIT_STYLIST, m_cstrStylist);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDialogNewProject, CDialog)
//{{AFX_MSG_MAP(CDialogNewProject)
ON_BN_CLICKED(IDC_RADIO_OILWELL, OnRadioOilwell)
ON_BN_CLICKED(IDC_RADIO_GASWELL, OnRadioGaswell)
ON_BN_CLICKED(IDC_BUTTON_SDT_BROWSE, OnButtonSdtBrowse)
ON_WM_DESTROY()
ON_BN_CLICKED(IDC_BUTTON_NEWPROJECT_BROWSE, OnButtonNewprojectBrowse)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDialogNewProject message handlers
void CDialogNewProject::OnRadioOilwell()
{
// TODO: Add your control notification handler code here
UpdateData();
m_iGasWell = -1;
m_iOilWell = 0;
UpdateData(FALSE);
}
void CDialogNewProject::OnRadioGaswell()
{
// TODO: Add your control notification handler code here
UpdateData();
m_iGasWell = 0;
m_iOilWell = -1;
UpdateData(FALSE);
}
void CDialogNewProject::OnButtonSdtBrowse()
{
// TODO: Add your control notification handler code here
CFileDialog fileDialog(
TRUE,"SDT",NULL,
OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST ,
"*.SDT|*.SDT|",
NULL);
fileDialog.m_ofn.lpstrInitialDir = theApp.m_strAppPath + _T("\\SK-Data\\"); // add by lzj
if(fileDialog.DoModal ()==IDCANCEL)
return;
CFile fileHandle;
char fileHead[6];
if(fileHandle.Open(
fileDialog.GetPathName() ,
CFile::modeRead))
{
CString cstrTemp;
cstrTemp = _T("[SDT]");
fileHandle.Read (fileHead,6);
fileHandle.Close ();
if(cstrTemp.Compare (fileHead) == 0)
{
UpdateData();
m_cstrSDTPath = fileDialog.GetPathName() ;
UpdateData(FALSE);
}
else
{
MessageBox("文件格式错误 !","错误");
}
}
else
{
MessageBox("文件不存在 !","错误");
}
}
void CDialogNewProject::OnDestroy()
{
CDialog::OnDestroy();
// TODO: Add your message handler code here
UpdateData();
if(m_iOilWell == 0)
m_bWellState = TRUE;
else
m_bWellState = FALSE;
UpdateData(FALSE);
}
void CDialogNewProject::OnOK()
{
// TODO: Add extra validation here
UpdateData();
if(m_cstrProjectPath.IsEmpty ())
{
MessageBox("请输入工程路径及名字 !","错误");
return;
}
if(m_cstrSDTPath.IsEmpty()
||m_cstrWellName.IsEmpty())
{
MessageBox("必须输入 井名与射孔弹型表 !","错误");
return;
}
UpdateData(FALSE);
CDialog::OnOK();
}
void CDialogNewProject::OnButtonNewprojectBrowse()
{
// TODO: Add your control notification handler code here
CFileDialog fileDialog(
TRUE,"SPD",NULL,
OFN_HIDEREADONLY|OFN_OVERWRITEPROMPT,
"*.SPD|*.SPD|",
NULL);
fileDialog.m_ofn.lpstrInitialDir = theApp.m_strAppPath + _T("\\SK-Data\\"); // add by lzj
if(fileDialog.DoModal ()==IDCANCEL)
return;
UpdateData();
m_cstrProjectPath = fileDialog.GetPathName ();
UpdateData(FALSE);
m_cstrProjectName = fileDialog.GetFileTitle ();
}
BOOL CDialogNewProject::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
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 + =
减小字号Ctrl + -
显示快捷键?