?? formatchangedlg.cpp
字號:
// 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 + -