📄 setfiledlg.cpp
字号:
// SETFILEDLG.cpp : implementation file
//
#include "stdafx.h"
#include "AccountInput.h"
#include "SETFILEDLG.h"
#include "DirDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSETFILEDLG dialog
CSETFILEDLG::CSETFILEDLG(CWnd* pParent /*=NULL*/)
: CDialog(CSETFILEDLG::IDD, pParent)
{
//{{AFX_DATA_INIT(CSETFILEDLG)
m_Radio3 = 0;
m_Radio5 = 0;
m_FileName = _T("");
m_AutoRun = FALSE;
m_LocalDir = _T("");
m_FTPDir = _T("");
m_strExportFile = _T("");
//}}AFX_DATA_INIT
}
void CSETFILEDLG::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSETFILEDLG)
DDX_Radio(pDX, IDC_RADIO3, m_Radio3);
DDX_Radio(pDX, IDC_RADIO5, m_Radio5);
DDX_Text(pDX, IDC_FILENAME, m_FileName);
DDX_Check(pDX, IDC_CHECK2, m_AutoRun);
DDX_Text(pDX, IDC_LOCAL_DIR, m_LocalDir);
DDX_Text(pDX, IDC_FTP_DIR, m_FTPDir);
DDX_Text(pDX, IDC_EDIT1, m_strExportFile);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSETFILEDLG, CDialog)
//{{AFX_MSG_MAP(CSETFILEDLG)
ON_BN_CLICKED(IDC_SELECT_FILE, OnSelectFile)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSETFILEDLG message handlers
BOOL CSETFILEDLG::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
TCHAR szFileName[MAX_PATH];
GetModuleFileName( NULL , szFileName , MAX_PATH );
szConfig = szFileName;
int nPos = szConfig.ReverseFind( '\\' );
szConfig = szConfig.Left( nPos );
szConfig += _T("\\MDT.ini") ;
//提示文字
m_ToolTip.Create(this);
m_ToolTip.Activate(TRUE);
m_ToolTip.SetTipTextColor(RGB(0,0,0)); //设置提示字体的着色
m_ToolTip.SetTipBkColor(RGB(127,255,212)); //设置提示框的背景着色
CWnd* pDlgName=GetDlgItem(IDC_FTP_DIR);//得到窗口指针
m_ToolTip.AddTool(pDlgName,_T("路徑格式:aaa/bbb/ccc,前后有無‘ / ’均可!"));//添加
//加载数据
DWORD nlength;
nlength=50;
LPTSTR pAutoRun,pReadOne,pFileSource,pLocalDir,pFTPDir,pFileName,pExportFile;
pAutoRun=new TCHAR[50];
pReadOne=new TCHAR[50];
pFileSource=new TCHAR[50];
pLocalDir=new TCHAR[50];
pFTPDir=new TCHAR[50];
pFileName=new TCHAR[50];
pExportFile=new TCHAR[50];
GetPrivateProfileString(_T("FileSetting"),_T("Auto"),_T("0"),pAutoRun,nlength,szConfig);
GetPrivateProfileString(_T("FileSetting"),_T("ReadOne"),_T("0"),pReadOne,nlength,szConfig);
GetPrivateProfileString(_T("FileSetting"),_T("FileSource"),_T("0"),pFileSource,nlength,szConfig);
GetPrivateProfileString(_T("FileSetting"),_T("LocalDir"),_T("0"),pLocalDir,nlength,szConfig);
GetPrivateProfileString(_T("FileSetting"),_T("FTPDir"),_T("0"),pFTPDir,nlength,szConfig);
GetPrivateProfileString(_T("FileSetting"),_T("FileName"),_T("0"),pFileName,nlength,szConfig);
GetPrivateProfileString(_T("FileSetting"),_T("ExportFile"),_T("0"),pExportFile,nlength,szConfig);
CString strAtuo,strSource,strReadOne,strFileSource;
strAtuo.Format(_T("%s"),pAutoRun);
strReadOne.Format(_T("%s"),pReadOne);
strSource.Format(_T("%s"),pFileSource);
m_LocalDir.Format(_T("%s"),pLocalDir);
m_FTPDir.Format(_T("%s"),pFTPDir);
m_FileName.Format(_T("%s"),pFileName);
m_strExportFile.Format(_T("%s"),pExportFile);
if (strReadOne==_T("YES"))
{
m_Radio3=0;
}
if (strReadOne==_T("NO"))
{
m_Radio3=1;
}
if (strSource==_T("FTP"))
{
m_Radio5=0;
}
if (strSource==_T("DEFINE"))
{
m_Radio5=1;
}
if (strAtuo==_T("YES"))
{
m_AutoRun=1;
}
if (strAtuo==_T("NO"))
{
m_AutoRun=0;
}
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CSETFILEDLG::OnOK()
{
// TODO: Add extra validation here
UpdateData(TRUE);
if (m_Radio3==0)
{
strReadOne="YES";
}
if (m_Radio3==1)
{
strReadOne="NO";
}
if (m_Radio5==0)
{
strFileSource="FTP";
}
if (m_Radio5==1)
{
strFileSource="DEFINE";
}
if (m_AutoRun)
{
strAuto="YES";
}
if (!m_AutoRun)
{
strAuto="NO";
}
WritePrivateProfileString( _T("FileSetting"), _T("ReadOne"), strReadOne, szConfig );
WritePrivateProfileString( _T("FileSetting"), _T("FileSource"), strFileSource, szConfig );
WritePrivateProfileString( _T("FileSetting"), _T("FileName"), m_FileName, szConfig );
WritePrivateProfileString( _T("FileSetting"), _T("LocalDir"), m_LocalDir, szConfig );
WritePrivateProfileString( _T("FileSetting"), _T("FTPDir"), m_FTPDir, szConfig );
WritePrivateProfileString( _T("FileSetting"), _T("Auto"), strAuto, szConfig );
WritePrivateProfileString( _T("FileSetting"), _T("ExportFile"), m_strExportFile, szConfig );
UpdateData(FALSE);
CDialog::OnOK();
}
void CSETFILEDLG::OnSelectFile()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
CString strFilePathName;
CDirDialog dlg;
if(dlg.DoBrowse(this)==IDOK)
{
m_LocalDir=dlg.m_strPath;
int nPos=m_LocalDir.Replace(_T("\\"),_T("\\\\"));
}
UpdateData(FALSE);
}
BOOL CSETFILEDLG::PreTranslateMessage(MSG * pMsg)
{
// TODO: Add your specialized code here and/or call the base class
//if(m_ToolTip.m_hWnd!=NULL)
{
m_ToolTip.RelayEvent(pMsg);//为提示窗口捕获鼠标消息
}
return CDialog::PreTranslateMessage(pMsg);
}
void CSETFILEDLG::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
//m_ToolTip.UpdateTipText("I LOVE YOU",GetDlgItem(IDC_FORM_NAME)); //提示内容
CDialog::OnMouseMove(nFlags, point);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -