www.pudn.com > DLT_Zhang.zip > ImportData.cpp, change:2011-06-08,size:3292b


// ImportData.cpp : implementation file 
// 
 
#include "stdafx.h" 
#include "DLT.h" 
#include "ImportData.h" 
#include <io.h> 
 
#ifdef _DEBUG 
#define new DEBUG_NEW 
#undef THIS_FILE 
static char THIS_FILE[] = __FILE__; 
#endif 
 
///////////////////////////////////////////////////////////////////////////// 
// ImportData dialog 
 
 
ImportData::ImportData(CWnd* pParent /*=NULL*/) 
	: CDialog(ImportData::IDD, pParent) 
{ 
	//{{AFX_DATA_INIT(ImportData) 
	m_strPath_Photo = _T(""); 
	m_strPath_Control = _T(""); 
	//}}AFX_DATA_INIT 
} 
 
 
void ImportData::DoDataExchange(CDataExchange* pDX) 
{ 
	CDialog::DoDataExchange(pDX); 
	//{{AFX_DATA_MAP(ImportData) 
	DDX_Text(pDX, IDC_EDIT1, m_strPath_Photo); 
	DDX_Text(pDX, IDC_EDIT2, m_strPath_Control); 
	//}}AFX_DATA_MAP 
} 
 
 
BEGIN_MESSAGE_MAP(ImportData, CDialog) 
	//{{AFX_MSG_MAP(ImportData) 
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1) 
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2) 
	//}}AFX_MSG_MAP 
END_MESSAGE_MAP() 
 
///////////////////////////////////////////////////////////////////////////// 
// ImportData message handlers 
 
void ImportData::OnButton1()  
{ 
	// TODO: Add your control notification handler code here 
	static int nIndex = 1; 
	char szFilter[] = "文本文档(*.txt)|*.txt||"; 
	 
	CFileDialog FileDlg( TRUE, NULL, NULL, OFN_HIDEREADONLY, szFilter ); 
	FileDlg.m_ofn.nFilterIndex = (DWORD) nIndex; 
	 
	int nStructSize = 0; 
	DWORD dwVersion, dwWindowsMajorVersion, dwWindwosMinorVersion; 
	dwVersion = GetVersion(); 
	dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion))); 
	dwWindwosMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion))); 
	if(dwVersion < 0x80000000) 
	{ 
		nStructSize = 88;   //2k,xp下显示新的版本 
	} 
	else 
	{ 
		nStructSize = 76;  //98下显示老版本,如图1 
	} 
	FileDlg.m_ofn.lStructSize = nStructSize;  //------用来检测目前的操作系统的版本信息 
	 
	if( FileDlg.DoModal() == IDOK ){ 
		CString str=FileDlg.GetPathName(); 
		m_strPath_Photo=str; 
		UpdateData(FALSE); 
	 } 
} 
 
void ImportData::OnButton2()  
{ 
	// TODO: Add your control notification handler code here 
	static int nIndex = 1; 
	char szFilter[] = "文本文档(*.txt)|*.txt||"; 
	 
	CFileDialog FileDlg( TRUE, NULL, NULL, OFN_HIDEREADONLY, szFilter ); 
	FileDlg.m_ofn.nFilterIndex = (DWORD) nIndex; 
	 
	int nStructSize = 0; 
	DWORD dwVersion, dwWindowsMajorVersion, dwWindwosMinorVersion; 
	dwVersion = GetVersion(); 
	dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion))); 
	dwWindwosMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion))); 
	if(dwVersion < 0x80000000) 
	{ 
		nStructSize = 88;   //2k,xp下显示新的版本 
	} 
	else 
	{ 
		nStructSize = 76;  //98下显示老版本,如图1 
	} 
	FileDlg.m_ofn.lStructSize = nStructSize;  //------用来检测目前的操作系统的版本信息 
	 
	if( FileDlg.DoModal() == IDOK ){ 
		CString str=FileDlg.GetPathName(); 
		m_strPath_Control=str; 
		UpdateData(FALSE); 
	 } 
} 
 
void ImportData::OnOK()  
{ 
	// TODO: Add extra validation here 
	UpdateData(TRUE); 
 
	if (_access(m_strPath_Photo, 0) == -1) 
	{ 
		AfxMessageBox("像素坐标文件不存在!",MB_OK,-1); 
		m_strPath_Photo=""; 
		UpdateData(FALSE); 
		return; 
	} 
 
	if (_access(m_strPath_Control, 0) == -1) 
	{ 
		AfxMessageBox("控制点文件不存在!",MB_OK,-1); 
		m_strPath_Control=""; 
		UpdateData(FALSE); 
		return; 
	} 
	CDialog::OnOK(); 
}