a
This commit is contained in:
@@ -0,0 +1,293 @@
|
||||
// SaveFilePathDlg.cpp : implementation file
|
||||
//
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "geomative.h"
|
||||
#include "SaveFilePathDlg.h"
|
||||
|
||||
#ifdef _DEBUG
|
||||
#define new DEBUG_NEW
|
||||
#undef THIS_FILE
|
||||
static char THIS_FILE[] = __FILE__;
|
||||
#endif
|
||||
|
||||
extern int g_iUILanguage;
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CSaveFilePathDlg dialog
|
||||
|
||||
|
||||
CSaveFilePathDlg::CSaveFilePathDlg(int iAR,CWnd* pParent /*=NULL*/)
|
||||
: CDialog(CSaveFilePathDlg::IDD, pParent)
|
||||
{
|
||||
//{{AFX_DATA_INIT(CSaveFilePathDlg)
|
||||
m_FilePath = _T("");
|
||||
//}}AFX_DATA_INIT
|
||||
m_iCurSel = -1;
|
||||
m_ucResFlag = 0;
|
||||
m_ProjectName = _T("");
|
||||
m_ZoneName = _T("");
|
||||
m_iAR = iAR;
|
||||
}
|
||||
|
||||
|
||||
void CSaveFilePathDlg::DoDataExchange(CDataExchange* pDX)
|
||||
{
|
||||
CDialog::DoDataExchange(pDX);
|
||||
//{{AFX_DATA_MAP(CSaveFilePathDlg)
|
||||
DDX_Text(pDX, IDC_FILEPATH, m_FilePath);
|
||||
//}}AFX_DATA_MAP
|
||||
}
|
||||
|
||||
|
||||
BEGIN_MESSAGE_MAP(CSaveFilePathDlg, CDialog)
|
||||
//{{AFX_MSG_MAP(CSaveFilePathDlg)
|
||||
ON_CBN_SELCHANGE(IDC_FILETYPE, OnSelchangeFiletype)
|
||||
ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
|
||||
//}}AFX_MSG_MAP
|
||||
END_MESSAGE_MAP()
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// CSaveFilePathDlg message handlers
|
||||
|
||||
BOOL CSaveFilePathDlg::OnInitDialog()
|
||||
{
|
||||
CDialog::OnInitDialog();
|
||||
|
||||
bSig = TRUE;
|
||||
// TODO: Add extra initialization here
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
{
|
||||
SetWindowText(_T("选择文件路径"));
|
||||
GetDlgItem(IDC_STATIC_FILE_PATH)->SetWindowText(_T("文件路径:"));
|
||||
GetDlgItem(IDC_STATIC_FILE_TYPE)->SetWindowText(_T("文件类型:"));
|
||||
GetDlgItem(IDC_BROWSE)->SetWindowText(_T("浏览"));
|
||||
GetDlgItem(IDOK)->SetWindowText(_T("确定"));
|
||||
GetDlgItem(IDCANCEL)->SetWindowText(_T("取消"));
|
||||
}
|
||||
//初始化控件内容
|
||||
GetDlgItem(IDC_CHECK_DAT)->EnableWindow(FALSE);
|
||||
GetDlgItem(IDC_CHECK_EXCEL)->EnableWindow(FALSE);
|
||||
GetDlgItem(IDC_CHECK_TXT)->EnableWindow(FALSE);
|
||||
GetDlgItem(IDC_CHECK_URF)->EnableWindow(FALSE);
|
||||
GetDlgItem(IDC_CHECK_CSV)->EnableWindow(FALSE);
|
||||
for (int n = 0; n < m_TypeArray.GetSize(); n++)
|
||||
{
|
||||
//只有垃圾填埋场装置需要支持csv文件导出
|
||||
if (AR_LAND_FILL_ONE == m_iAR || AR_LAND_FILL_TWO == m_iAR)
|
||||
{
|
||||
if (m_TypeArray.GetAt(n) == _T("Csv"))
|
||||
{
|
||||
GetDlgItem(IDC_CHECK_CSV)->EnableWindow(TRUE);
|
||||
//((CButton*)(GetDlgItem(IDC_CHECK_CSV)))->SetCheck(BST_CHECKED);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_TypeArray.GetAt(n) == _T("Csv"))
|
||||
{
|
||||
GetDlgItem(IDC_CHECK_CSV)->EnableWindow(TRUE);
|
||||
//((CButton*)(GetDlgItem(IDC_CHECK_CSV)))->SetCheck(BST_CHECKED);
|
||||
continue;
|
||||
}
|
||||
if (m_TypeArray.GetAt(n) == "Dat")
|
||||
{
|
||||
GetDlgItem(IDC_CHECK_DAT)->EnableWindow(TRUE);
|
||||
((CButton*)(GetDlgItem(IDC_CHECK_DAT)))->SetCheck(BST_CHECKED);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (m_TypeArray.GetAt(n) == "Excel")
|
||||
{
|
||||
GetDlgItem(IDC_CHECK_EXCEL)->EnableWindow(TRUE);
|
||||
//((CButton*)(GetDlgItem(IDC_CHECK_EXCEL)))->SetCheck(BST_CHECKED);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (m_TypeArray.GetAt(n) == "Txt")
|
||||
{
|
||||
GetDlgItem(IDC_CHECK_TXT)->EnableWindow(TRUE);
|
||||
//((CButton*)(GetDlgItem(IDC_CHECK_TXT)))->SetCheck(BST_CHECKED);
|
||||
}
|
||||
if (m_TypeArray.GetAt(n) == "Urf")
|
||||
{
|
||||
GetDlgItem(IDC_CHECK_URF)->EnableWindow(TRUE);
|
||||
//((CButton*)(GetDlgItem(IDC_CHECK_URF)))->SetCheck(BST_CHECKED);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// m_FileType.SetCurSel(0);
|
||||
|
||||
//初始化文件路径控件
|
||||
// int nID = m_FileType.GetCurSel();
|
||||
|
||||
// CString szType = _T("");
|
||||
// m_FileType.GetLBText(nID,szType);
|
||||
if (m_FilePath.IsEmpty())
|
||||
{
|
||||
// m_FilePath = m_CurrentPath + "\\" + _T("Data") + "\\" + m_ProjectName + "\\" + m_ZoneName + "\\";
|
||||
m_FilePath = m_CurrentPath + "\\" + _T("Data") + "\\" + m_ProjectName + "\\";
|
||||
}
|
||||
|
||||
UpdateData(FALSE);
|
||||
|
||||
return TRUE; // return TRUE unless you set the focus to a control
|
||||
// EXCEPTION: OCX Property Pages should return FALSE
|
||||
}
|
||||
|
||||
void CSaveFilePathDlg::OnSelchangeFiletype()
|
||||
{
|
||||
// TODO: Add your control notification handler code here
|
||||
UpdateData(TRUE);
|
||||
|
||||
// int nID = m_FileType.GetCurSel();
|
||||
|
||||
CString szType = _T("");
|
||||
// m_FileType.GetLBText(nID,szType);
|
||||
|
||||
if (!bSig)
|
||||
{
|
||||
m_FilePath = m_CurrentPath + "\\" + szType + "\\" + m_ProjectName + "\\" + m_ZoneName + "\\";
|
||||
}
|
||||
|
||||
UpdateData(FALSE);
|
||||
}
|
||||
|
||||
void CSaveFilePathDlg::OnBrowse()
|
||||
{
|
||||
// TODO: Add your control notification handler code here
|
||||
CString szResult = _T("");
|
||||
szResult = GetFilePath();
|
||||
|
||||
if (szResult != "null")
|
||||
{
|
||||
m_FilePath.Empty();
|
||||
m_FilePath = szResult+_T("\\");
|
||||
UpdateData(FALSE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
CString CSaveFilePathDlg::GetFilePath()
|
||||
{
|
||||
LPITEMIDLIST rootLoation;
|
||||
BROWSEINFO bi;
|
||||
TCHAR targetPath[ MAX_PATH ];
|
||||
// static TCHAR targetPath2[ MAX_PATH ];
|
||||
SHGetSpecialFolderLocation( NULL, CSIDL_DESKTOP, &rootLoation );
|
||||
ZeroMemory( &bi, sizeof( bi ) );
|
||||
bi.pidlRoot = rootLoation;
|
||||
bi.lpszTitle = _T( "保存路径" );
|
||||
|
||||
LPITEMIDLIST targetLocation = SHBrowseForFolder( &bi );
|
||||
|
||||
if ( targetLocation != NULL )
|
||||
{
|
||||
SHGetPathFromIDList( targetLocation, targetPath );
|
||||
// int id,id2,id3;
|
||||
// memset(targetPath2,0,MAX_PATH);
|
||||
// for(id=0,id2=0;id<strlen(targetPath);id++,id2++)
|
||||
// {
|
||||
// if(targetPath[id] == '\\')
|
||||
// {
|
||||
// targetPath2[id2] = targetPath[id];
|
||||
// id2++;
|
||||
// targetPath2[id2] = '\\';
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// targetPath2[id2] = targetPath[id];
|
||||
// }
|
||||
// id3=id2;
|
||||
// }
|
||||
// id3++;
|
||||
// targetPath2[id3] = '\\';
|
||||
// id3++;
|
||||
// targetPath2[id3] = '\\';
|
||||
|
||||
CString szPath(targetPath);
|
||||
|
||||
bSig = TRUE;//表示使用自定义路径
|
||||
return szPath;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "null";
|
||||
}
|
||||
}
|
||||
|
||||
void CSaveFilePathDlg::OnOK()
|
||||
{
|
||||
// TODO: Add extra validation here
|
||||
// m_FilePath = "E:\\code\\Release_Code\\Geomative相关\\Trunk_1.0.3\\Dat\\project1\\z4\\";
|
||||
UpdateData(TRUE);
|
||||
if (!MakeSureDirectoryPathExists(m_FilePath.GetBuffer(m_FilePath.GetLength())))
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("路径被占用,请关闭!"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("The Path is occupy, Please Close it"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
m_ucResFlag = 0;
|
||||
if (BST_CHECKED == ((CButton*)(GetDlgItem(IDC_CHECK_DAT)))->GetCheck())
|
||||
{
|
||||
m_ucResFlag = m_ucResFlag | 0x01;
|
||||
}
|
||||
|
||||
if (BST_CHECKED == ((CButton*)(GetDlgItem(IDC_CHECK_EXCEL)))->GetCheck())
|
||||
{
|
||||
m_ucResFlag = m_ucResFlag | 0x02;
|
||||
}
|
||||
|
||||
if (BST_CHECKED == ((CButton*)(GetDlgItem(IDC_CHECK_TXT)))->GetCheck())
|
||||
{
|
||||
m_ucResFlag = m_ucResFlag | 0x04;
|
||||
}
|
||||
|
||||
if (BST_CHECKED == ((CButton*)(GetDlgItem(IDC_CHECK_URF)))->GetCheck())
|
||||
{
|
||||
m_ucResFlag = m_ucResFlag | 0x08;
|
||||
}
|
||||
|
||||
if (BST_CHECKED == ((CButton*)(GetDlgItem(IDC_CHECK_CSV)))->GetCheck())
|
||||
{
|
||||
m_ucResFlag = m_ucResFlag | 0x10;
|
||||
}
|
||||
|
||||
if (0 == m_ucResFlag)
|
||||
{
|
||||
if (LANG_ZHCN == g_iUILanguage)
|
||||
AfxMessageBox(_T("路请选择文件类型!"));
|
||||
else
|
||||
MessageBoxEx(NULL, _T("Please select file type!"), STRING_MESSAGEBOXEX_TITLE, MB_OK, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US));
|
||||
return;
|
||||
}
|
||||
m_szFileName = m_FilePath + m_TaskName;
|
||||
/*
|
||||
|
||||
int nID = m_FileType.GetCurSel();
|
||||
CString szFileType = _T("");
|
||||
|
||||
m_FileType.GetLBText(nID, szFileType);
|
||||
|
||||
if (szFileType == "Dat")
|
||||
{
|
||||
m_szFileName = m_FilePath + m_TaskName + ".dat";
|
||||
m_iCurSel = 1;
|
||||
}
|
||||
else if (szFileType == "Excel")
|
||||
{
|
||||
m_szFileName = m_FilePath + m_TaskName + ".xlsx";
|
||||
m_iCurSel = 0;
|
||||
}
|
||||
else if (szFileType == "Txt")
|
||||
{
|
||||
m_szFileName = m_FilePath + m_TaskName + ".txt";
|
||||
m_iCurSel = 2;
|
||||
}
|
||||
*/
|
||||
CDialog::OnOK();
|
||||
}
|
||||
Reference in New Issue
Block a user