📄 flippage.cpp
字号:
// FlipPage.cpp : implementation file
/*********************************************************************
* Author: Simon Wang
* Date: 2000-11-16
* 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 "FlipPage.h"
#include "Globals.h"
#include "Common\DirDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CFlipPage property page
IMPLEMENT_DYNCREATE(CFlipPage, CPropertyPage)
CFlipPage::CFlipPage() : CPropertyPage(CFlipPage::IDD)
{
//{{AFX_DATA_INIT(CFlipPage)
//}}AFX_DATA_INIT
}
CFlipPage::~CFlipPage()
{
}
void CFlipPage::DoDataExchange(CDataExchange* pDX)
{
CPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CFlipPage)
DDX_Control(pDX, IDC_BTN_ADDFLPPATH, m_btnAdd);
DDX_Control(pDX, IDC_BTN_DELFLPPATH, m_btnDel);
DDX_Control(pDX, IDC_BTN_UPFLPPATH, m_btnUp);
DDX_Control(pDX, IDC_BTN_DOWNFLPPATH, m_btnDown);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CFlipPage, CPropertyPage)
//{{AFX_MSG_MAP(CFlipPage)
ON_BN_CLICKED(IDC_BTN_ADDFLPPATH, OnBtnAddflppath)
ON_BN_CLICKED(IDC_BTN_DELFLPPATH, OnBtnDelflppath)
ON_BN_CLICKED(IDC_BTN_UPFLPPATH, OnBtnUpflppath)
ON_BN_CLICKED(IDC_BTN_DOWNFLPPATH, OnBtnDownflppath)
ON_LBN_SELCHANGE(IDC_LIST_PATH, OnSelchangeListPath)
ON_EN_CHANGE(IDC_EDIT_HEADFILE, OnChangeEditHeadfile)
ON_EN_CHANGE(IDC_EDIT_CPPFILE, OnChangeEditCppfile)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CFlipPage message handlers
BOOL CFlipPage::OnApply()
{
CString strTmp;
CIni ini(g_szIniPathName);
g_strAFlipPath.RemoveAll();
for(int i = 0; i < m_strAPath.GetSize(); i++)
{
if(m_szSelect[i] == _T('1'))
g_strAFlipPath.Add(m_strAPath[i]);
}
m_szSelect[m_strAPath.GetSize()] = _T('\0');
// m_strAPath.RemoveAt(0);
CStringArray strATmp;
strATmp.Copy(m_strAPath);
strATmp.RemoveAt(0);
CombineString(strATmp,strTmp);
ini.SetMultiValue(lpszFlip,lpszFlipPath,strTmp);
ini.SetValue(lpszFlip,lpszSelectPortion,&(m_szSelect[1]));//+1);
strATmp.RemoveAll();
GetDlgItemText(IDC_EDIT_HEADFILE,g_szHeadType,128);
_tcslwr(g_szHeadType);
ini.SetValue(lpszFlip,lpszHeadType,g_szHeadType);
GetDlgItemText(IDC_EDIT_CPPFILE,g_szCPPType,128);
_tcslwr(g_szCPPType);
ini.SetValue(lpszFlip,lpszCppType,g_szCPPType);
ini.Write(g_szIniPathName);
ini.Clear();
return CPropertyPage::OnApply();
}
BOOL CFlipPage::OnInitDialog()
{
CPropertyPage::OnInitDialog();
m_lstPath.SubclassDlgItem(IDC_LIST_PATH, this);
LPINT lpTabStop = new int[1];
lpTabStop[0] = 22;
m_lstPath.SetTabStops(1, lpTabStop);
delete[] lpTabStop;
CIni ini(g_szIniPathName);
CString strTmp;
ini.GetMultiValue(lpszFlip,lpszFlipPath,strTmp);
m_strAPath.RemoveAll();
SplitString(strTmp,m_strAPath);
ini.GetValue(lpszFlip,lpszSelectPortion,&(m_szSelect[1]));//m_szSelect+1);
//m_szSelect[0],m_strAPath[0] is default path
m_szSelect[0] = _T('1');
m_strAPath.InsertAt(0,lpszSameDir,1);
TCHAR szBuf[128];
ini.GetValue(lpszFlip,lpszHeadType,szBuf,g_szHeadType);
SetDlgItemText(IDC_EDIT_HEADFILE,szBuf);
ini.GetValue(lpszFlip,lpszCppType,szBuf,g_szCPPType);
SetDlgItemText(IDC_EDIT_CPPFILE,szBuf);
ini.Clear();
int size = m_strAPath.GetSize();
for(int i = 0; i < size; i++)
{
strTmp.Format(_T("%s\t%s"), lpszNull,m_strAPath[i]);
m_lstPath.AddString(strTmp);
m_lstPath.SetCheck(i,(m_szSelect[i] == _T('1')) ? 1 : 0);
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CFlipPage::OnBtnAddflppath()
{
CDirDialog dlg;
CString strTmp;
strTmp = g_strPrjSetFile;
int idx = strTmp.ReverseFind(_T('\\'));
strTmp = strTmp.Left(idx);
#ifdef _VER_CHINESE
if(dlg.DoBrowse(this,_T("添加 CPP/H 文件切换搜索路径"),lpszNull,strTmp) == 1)
#else
if(dlg.DoBrowse(this,_T("Add search path for CPP/H file switch"),lpszNull,strTmp) == 1)
#endif
{
int size = m_strAPath.GetSize();
if(size >= 63)
{
#ifdef _VER_CHINESE
AfxMessageBox(_T("当前搜索路径太多(多于64个), 请删除一些不再使用的搜索路径.\
\r\n(搜索路径太多会减慢搜索速度)"));
#else
AfxMessageBox(_T("too much search path you setted(more than 64), please remove some no longer use path.\
\r\n(too much search path would slowed the speed of file switch)"));
#endif
return;
}
for(int i = 0; i < m_strAPath.GetSize(); i++)
{
if(m_strAPath[i] == dlg.m_strPath)
return;
}
strTmp.Format(_T("%s\t%s"), lpszNull,dlg.m_strPath + _T("\\"));
m_lstPath.AddString(strTmp);
m_strAPath.Add(dlg.m_strPath + _T("\\"));
m_szSelect[size] = _T('1');
m_lstPath.SetCheck(size,(m_szSelect[size] == _T('1')) ? 1 : 0);
SetModified();
}
}
void CFlipPage::OnBtnDelflppath()
{
int idx = m_lstPath.GetCurSel();
int count = m_strAPath.GetSize();
if((idx <= 0) || (idx >= count))
return;
m_lstPath.DeleteString(idx);
m_strAPath.RemoveAt(idx);
for(int i = idx; i < count - 1; i++)
m_szSelect[idx] = m_szSelect[idx + 1];
SetModified();
}
void CFlipPage::OnBtnUpflppath()
{
int idx = m_lstPath.GetCurSel();
int count = m_strAPath.GetSize();
if((idx < 2) || (idx >= count))
return;
//ListBox control exchange
CString strTmp;
m_lstPath.GetText(idx - 1,strTmp);
m_lstPath.DeleteString(idx - 1);
m_lstPath.InsertString(idx,strTmp);
//check mark array exchange
TCHAR cTmp = m_szSelect[idx - 1];
m_szSelect [idx - 1] = m_szSelect[idx];
m_szSelect[idx] = cTmp;
m_lstPath.SetCheck(idx,(m_szSelect[idx] == _T('1')) ? 1 : 0);
//m_strAPath exchange
strTmp = m_strAPath[idx - 1];
m_strAPath.SetAt(idx - 1,m_strAPath[idx]);
m_strAPath.SetAt(idx,strTmp);
SetModified();
}
void CFlipPage::OnBtnDownflppath()
{
int idx = m_lstPath.GetCurSel();
int count = m_strAPath.GetSize();
if((idx <= 0) || (idx >= count - 1))
return;
//ListBox control exchange
CString strTmp;
m_lstPath.GetText(idx + 1,strTmp);
m_lstPath.DeleteString(idx + 1);
m_lstPath.InsertString(idx,strTmp);
//check mark array exchange
TCHAR cTmp = m_szSelect[idx + 1];
m_szSelect [idx + 1] = m_szSelect[idx];
m_szSelect[idx] = cTmp;
m_lstPath.SetCheck(idx,(m_szSelect[idx] == _T('1')) ? 1 : 0);
//m_strAPath exchange
strTmp = m_strAPath[idx + 1];
m_strAPath.SetAt(idx + 1,m_strAPath[idx]);
m_strAPath.SetAt(idx,strTmp);
SetModified();
}
void CFlipPage::OnSelchangeListPath()
{
//do nothing when select the first item
int idx = m_lstPath.GetCurSel();
int oldStatus = (m_szSelect[idx] == _T('1') ) ? 1 : 0;
int bCheck = m_lstPath.GetCheck(idx);
if(bCheck != oldStatus)
{
if(idx > 0)
m_szSelect[idx] = (bCheck == 1) ? _T('1') : _T('0');
SetModified();
}
}
void CFlipPage::OnChangeEditHeadfile()
{
SetModified();
}
void CFlipPage::OnChangeEditCppfile()
{
SetModified();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -