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

📄 formatchangedlg.cpp

📁 MAPINFO各式转换极为TXT---->MIDMIF
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// FormatChangeDlg.cpp : implementation file
//

#include "stdafx.h"
#include "FormatChange.h"
#include "FormatChangeDlg.h"
#include <fstream>
#include <vector>
#include <string>

using namespace std;

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

/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About

class CAboutDlg : public CDialog
{
public:
	CAboutDlg();

// Dialog Data
	//{{AFX_DATA(CAboutDlg)
	enum { IDD = IDD_ABOUTBOX };
	CString	m_aboutinfo;
	//}}AFX_DATA

	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CAboutDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:
	//{{AFX_MSG(CAboutDlg)
	virtual BOOL OnInitDialog();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
	//{{AFX_DATA_INIT(CAboutDlg)
	m_aboutinfo = _T("");
	//}}AFX_DATA_INIT
}

void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CAboutDlg)
	DDX_Text(pDX, IDC_ABOUTINFO, m_aboutinfo);
	//}}AFX_DATA_MAP
}

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

/////////////////////////////////////////////////////////////////////////////
// CFormatChangeDlg dialog

CFormatChangeDlg::CFormatChangeDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CFormatChangeDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CFormatChangeDlg)
	m_openpath = _T("");
	m_defaultpath = _T("");
	m_userpath = _T("");
	m_selformat = -1;
	m_info = _T("");
	m_seloutpath = -1;
	//}}AFX_DATA_INIT
	// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}

void CFormatChangeDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CFormatChangeDlg)
	DDX_Text(pDX, IDC_OPEN, m_openpath);
	DDX_Text(pDX, ID_DEFALTPATH, m_defaultpath);
	DDX_Text(pDX, ID_USERPATH, m_userpath);
	DDX_Radio(pDX, IDC_SINGLE, m_selformat);
	DDX_Text(pDX, IDC_INFO, m_info);
	DDX_Radio(pDX, IDC_DEFAULTPATH, m_seloutpath);
	//}}AFX_DATA_MAP
}

BEGIN_MESSAGE_MAP(CFormatChangeDlg, CDialog)
	//{{AFX_MSG_MAP(CFormatChangeDlg)
	ON_WM_SYSCOMMAND()
	ON_WM_PAINT()
	ON_WM_QUERYDRAGICON()
	ON_BN_CLICKED(ID_CHANGE, OnChange)
	ON_BN_CLICKED(ID_ABOUTINFO, OnAboutinfo)
	ON_BN_CLICKED(ID_LOOKPAHT, OnLookpaht)
	ON_BN_CLICKED(IDC_OPENPATH, OnOpenpath)
	ON_BN_CLICKED(IDC_USERPATH, OnUserpath)
	ON_BN_CLICKED(IDC_DEFAULTPATH, OnDefaultpath)
	ON_BN_CLICKED(IDC_SINGLE, OnSingle)
	ON_BN_CLICKED(IDC_BATCH, OnBatch)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CFormatChangeDlg message handlers

BOOL CFormatChangeDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// Add "About..." menu item to system menu.

	// IDM_ABOUTBOX must be in the system command range.
	ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
	ASSERT(IDM_ABOUTBOX < 0xF000);

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
	{
		CString strAboutMenu;
		strAboutMenu.LoadString(IDS_ABOUTBOX);
		if (!strAboutMenu.IsEmpty())
		{
			pSysMenu->AppendMenu(MF_SEPARATOR);
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
		}
	}

	// Set the icon for this dialog.  The framework does this automatically
	//  when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon
	
	// TODO: Add extra initialization here
	UpdateData(true);	//设置默认处理方式为单个处理
	m_selformat=0;
	m_seloutpath=0;		//设置默认输出路径

	m_userpath="";
	m_defaultpath="";

	CString m="   Hello,welcome here!感谢您使用EMG文件转换器工具,请您多多提出宝贵的意见!";
	m_info=m;	
	GetDlgItem(IDC_OPENPATH)->SetFocus();
//	GetDlgItem(ID_LOOKPAHT)->EnableWindow(false);
	UpdateData(false);
	return TRUE;  // return TRUE  unless you set the focus to a control
}

void CFormatChangeDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
	{
		CAboutDlg dlgAbout;
		dlgAbout.DoModal();
	}
	else
	{
		CDialog::OnSysCommand(nID, lParam);
	}
}

// If you add a minimize button to your dialog, you will need the code below
//  to draw the icon.  For MFC applications using the document/view model,
//  this is automatically done for you by the framework.

void CFormatChangeDlg::OnPaint() 
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);
	}
	else
	{
		CDialog::OnPaint();
	}
}

// The system calls this to obtain the cursor to display while the user drags
//  the minimized window.
HCURSOR CFormatChangeDlg::OnQueryDragIcon()
{
	return (HCURSOR) m_hIcon;
}

BOOL CAboutDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	UpdateData(true);
	m_aboutinfo="   本软件是由EMG公司开发的转换工具,它可以将具备一定格式的TXT文件数据转换成MIF和MID文件,从而可以在MapInfo工具中转换成所需要的TAB表文件!并且文件转换过程会有大量信息提示,以方便您的操作!";
	UpdateData(false);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CFormatChangeDlg::OnChange() 
{
	// TODO: Add your control notification handler code here
	CString stroutmif,stroutmid,stropenfile;
	UpdateData(true);
	GetDlgItem(ID_LOOKPAHT)->EnableWindow();

	if(m_selformat==0)//单步处理
	{
		if(m_openpath=="")
		{
			AfxMessageBox("您未选择输入文件的路径!");
		}
		else
		{
			if(m_seloutpath==0)
			{//默认路径
				stropenfile=m_openpath;
				stroutmif=m_openpath.Mid(0,strlen(m_openpath)-strlen(strExt)-1)+".mif";
				stroutmid=m_openpath.Mid(0,strlen(m_openpath)-strlen(strExt)-1)+".mid";
				m_info=Ch(stropenfile,stroutmif,stroutmid);
				m_defaultpath=m_openpath.Mid(0,strlen(m_openpath)-strlen(strExt)-strlen(strFilename)-1);
			}
			else
			{//自定义路径
				if(m_userpath=="")
				{
					MessageBox("您并未设定文件输出路径!","Warning!!!");
				}
				else
				{
					stropenfile=m_openpath;
					stroutmif=m_userpath+strFilename+".mif";
					stroutmid=m_userpath+strFilename+".mid";
					m_info=Ch(stropenfile,stroutmif,stroutmid);
				}
			}
		}
	}
	else//批处理
	{
		if(m_openpath=="")
		{
			AfxMessageBox("您未选择输入文件的路径!!");
		}
		else
		{
			if(m_seloutpath==0)
			{//默认路径
				CStdioFile Exportfile;
				CString str;
				Exportfile.Open("D:\path.txt",CFile::modeRead,NULL);
				Exportfile.GetFileName();
				while(Exportfile.ReadString(str))
				{   
					strFilename=Exportfile.GetFileName();
					stropenfile=str;
					stroutmif=str.Mid(0,strlen(str)-4)+".mif";
					stroutmid=str.Mid(0,strlen(str)-4)+".mid";
					m_info=Ch(stropenfile,stroutmif,stroutmid);
					m_defaultpath=str.Mid(0,strlen(str)-3-strlen(strFilename)-1);
				}
			}
			else
			{//自定义路径
				if(m_userpath=="")
				{
					MessageBox("您并未设定文件输出路径!","Warning!!!");
				}
				else
				{
					CStdioFile Exportfile;
					CString str;
					Exportfile.Open("D:\path.txt",CFile::modeRead,NULL);
					Exportfile.GetFileName();
					while(Exportfile.ReadString(str))
					{   
						strFilename=Exportfile.GetFileName();
						stropenfile=str;
						stroutmif=m_userpath+strFilename+".mif";
						stroutmid=m_userpath+strFilename+".mid";
						m_info=Ch(stropenfile,stroutmif,stroutmid);
					}
				}
			}
		}
//	应该删除path.txt
	}

⌨️ 快捷键说明

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