📄 zippage.cpp
字号:
// ZipPage.cpp : implementation file
/*********************************************************************
* Author: Simon Wang
* Date: 2003-7-30
* Contact us: inte2000@263.net
* Web Page: http://www.winmsg.com/cn/orbit.htm (for Chinese version)
* http://www.winmsg.com/orbit.htm (for English version)
**********************************************************************/
#include "stdafx.h"
#include "tabbars.h"
#include "ZipPage.h"
#include "Globals.h"
#include "Common\DirDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CZipPage property page
IMPLEMENT_DYNCREATE(CZipPage, CPropertyPage)
CZipPage::CZipPage() : CPropertyPage(CZipPage::IDD)
{
//{{AFX_DATA_INIT(CZipPage)
m_bOpenCheck = FALSE;
m_nRadFileType = -1;
//}}AFX_DATA_INIT
}
CZipPage::~CZipPage()
{
}
void CZipPage::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CZipPage)
DDX_Check(pDX, IDC_CHK_OPENCHECK, m_bOpenCheck);
DDX_Radio(pDX, IDC_RAD_ALLFILE, m_nRadFileType);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CZipPage, CPropertyPage)
//{{AFX_MSG_MAP(CZipPage)
ON_BN_CLICKED(IDC_BTN_PATH, OnBtnPath)
ON_EN_CHANGE(IDC_EDIT_UNZIPPATH, OnChangeEditUnzippath)
ON_EN_CHANGE(IDC_EDIT_ZIPFILETYPE, OnChangeEditZipfiletype)
ON_BN_CLICKED(IDC_CHK_OPENCHECK, OnChkOpencheck)
ON_BN_CLICKED(IDC_RAD_ALLFILE, OnRadAllfile)
ON_BN_CLICKED(IDC_RAD_SELECTFILE, OnRadSelectfile)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CZipPage message handlers
BOOL CZipPage::OnInitDialog()
{
CPropertyPage::OnInitDialog();
CIni ini(g_szIniPathName);
ini.GetBoolValue(lpszZip,_T("bOpenCheck"),m_bOpenCheck);
BOOL bZipall;
ini.GetBoolValue(lpszZip,_T("bZipAllFile"),bZipall);
m_nRadFileType = bZipall ? 0 : 1;
CString strTmp;
ini.GetValue(lpszZip,_T("sZipFileType"),strTmp);
SetDlgItemText(IDC_EDIT_ZIPFILETYPE,strTmp);
ini.GetValue(lpszZip,_T("sUnzipPath"),strTmp);
SetDlgItemText(IDC_EDIT_UNZIPPATH,strTmp);
GetDlgItem(IDC_EDIT_ZIPFILETYPE)->EnableWindow(!bZipall);
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CZipPage::OnBtnPath()
{
CDirDialog dlg;
CString strTmp;
GetDlgItemText(IDC_EDIT_UNZIPPATH,strTmp);
#ifdef _VER_CHINESE
if(dlg.DoBrowse(this,_T("选择解压缩目录"),lpszNull,strTmp) == 1)
#else
if(dlg.DoBrowse(this,_T("Select Folder to Extract To"),lpszNull,strTmp) == 1)
#endif
{
SetDlgItemText(IDC_EDIT_UNZIPPATH,dlg.m_strPath);
SetModified();
}
}
BOOL CZipPage::OnApply()
{
UpdateData(TRUE);
CString FileType;
GetDlgItemText(IDC_EDIT_ZIPFILETYPE,FileType);
//check the validity of this string
CStringArray arTypes;
int nCount = SplitFileTypeString(FileType,arTypes);
int nSize = arTypes.GetSize();
ASSERT(nCount == nSize);
BOOL bValidate = TRUE;
for(int i = 0; i < nSize; i++)
{
if(arTypes[i].GetLength() <= 0 || arTypes[i][0] != _T('.'))
{
bValidate = FALSE;
break;
}
}
if(!bValidate)//not validated
{
#ifdef _VER_CHINESE
AfxMessageBox(_T("文件类型的输入不符合格式,请重新输入!"));
#else
AfxMessageBox(_T("File type string format is validated!"));
#endif
return FALSE;
}
CString strPath;
GetDlgItemText(IDC_EDIT_UNZIPPATH,strPath);
int nLength = strPath.GetLength();
if(nLength > 2 && strPath[nLength - 2] == _T(':'))//do not trim '\' char in that case "c:\"
{
strPath.TrimRight(_T('\\'));
}
if(GetFileAttributes(strPath) == 0xffffffff)//not exist
{
CString strTmp;
#ifdef _VER_CHINESE
strTmp.Format(_T("目录 %s \r\n不存在或者没有访问权限!"),strPath);
#else
strTmp.Format(_T("The folder '%s' \r\nis not exist or you have not enough right to access"),strPath);
#endif
AfxMessageBox(strTmp);
return FALSE;
}
BOOL bZipAll = (m_nRadFileType == 0) ? TRUE : FALSE;
CIni ini(g_szIniPathName);
ini.SetBoolValue(lpszZip,_T("bOpenCheck"),m_bOpenCheck);
ini.SetBoolValue(lpszZip,_T("bZipAllFile"),bZipAll);
ini.SetValue(lpszZip,_T("sZipFileType"),FileType);
ini.SetValue(lpszZip,_T("sUnzipPath"),strPath);
ini.Write(g_szIniPathName);
return CPropertyPage::OnApply();
}
void CZipPage::OnChangeEditUnzippath()
{
SetModified();
}
void CZipPage::OnChangeEditZipfiletype()
{
SetModified();
}
void CZipPage::OnChkOpencheck()
{
SetModified();
}
void CZipPage::OnRadAllfile()
{
int oldtype = m_nRadFileType;
UpdateData(TRUE);
if(oldtype != m_nRadFileType)
SetModified();
GetDlgItem(IDC_EDIT_ZIPFILETYPE)->EnableWindow(FALSE);
}
void CZipPage::OnRadSelectfile()
{
int oldtype = m_nRadFileType;
UpdateData(TRUE);
if(oldtype != m_nRadFileType)
SetModified();
GetDlgItem(IDC_EDIT_ZIPFILETYPE)->EnableWindow(TRUE);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -