📄 setproxydlg.cpp
字号:
// SetProxyDlg.cpp : implementation file
//
#include "stdafx.h"
#include "benbenbrowser.h"
#include "SetProxyDlg.h"
#include "generaldata.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSetProxyDlg dialog
CSetProxyDlg::CSetProxyDlg(CWnd* pParent /*=NULL*/)
: CDialog(CSetProxyDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CSetProxyDlg)
m_local_pass = FALSE;
//}}AFX_DATA_INIT
}
void CSetProxyDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CSetProxyDlg)
DDX_Control(pDX, IDC_LIST_PROXY, m_listctrl);
DDX_Control(pDX, IDC_EDIT_URL1, m_urlctrl);
DDX_Control(pDX, IDC_EDIT_TITLE1, m_titlectrl);
DDX_Control(pDX, IDC_EDIT_PORT1, m_portctrl);
DDX_Check(pDX, IDC_CHECK_LOCAL, m_local_pass);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CSetProxyDlg, CDialog)
//{{AFX_MSG_MAP(CSetProxyDlg)
ON_BN_CLICKED(IDC_BUTTON_ACTION1, OnButtonAction1)
ON_BN_CLICKED(IDC_BUTTON_DELETE1, OnButtonDelete1)
ON_BN_CLICKED(IDC_BUTTON_INSERT1, OnButtonInsert1)
ON_BN_CLICKED(IDC_BUTTON_UPDATE1, OnButton1Update)
ON_BN_CLICKED(IDC_BUTTON_CANCEL1, OnButtonCancel1)
ON_WM_CLOSE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSetProxyDlg message handlers
void CSetProxyDlg::OnButtonAction1()
{
// TODO: Add your control notification handler code here
CString title,url,port;
m_titlectrl.GetWindowText(title);
m_urlctrl.GetWindowText(url);
m_portctrl.GetWindowText(port);
if(title.GetLength()<=0||url.GetLength()<=0)
return;
if(m_action==1)//new
{
m_listctrl.InsertItem(m_listctrl.GetItemCount(),title);
m_listctrl.SetItem(m_listctrl.GetItemCount()-1,1,LVIF_TEXT,url,0,0,0,0);
m_listctrl.SetItem(m_listctrl.GetItemCount()-1,2,LVIF_TEXT,port,0,0,0,0);
}
else if(m_action==3)//update
{
POSITION pos = m_listctrl.GetFirstSelectedItemPosition();
if(!pos)
return;
int index=m_listctrl.GetNextSelectedItem(pos);
m_listctrl.SetItem(index,0,LVIF_TEXT,title,0,0,0,0);
m_listctrl.SetItem(index,1,LVIF_TEXT,url,0,0,0,0);
m_listctrl.SetItem(index,2,LVIF_TEXT,port,0,0,0,0);
}
}
void CSetProxyDlg::OnButtonDelete1()
{
// TODO: Add your control notification handler code here
POSITION pos = m_listctrl.GetFirstSelectedItemPosition();
if(!pos)
return;
int index=m_listctrl.GetNextSelectedItem(pos);
m_listctrl.DeleteItem(index);
}
void CSetProxyDlg::OnButtonInsert1()
{
// TODO: Add your control notification handler code here
ExpandDialog(TRUE);
CString btntitle;
GetDlgItemText(IDC_BUTTON_INSERT1,btntitle);
SetDlgItemText(IDC_BUTTON_ACTION1,btntitle);
m_titlectrl.SetWindowText("");
m_urlctrl.SetWindowText("");
m_action=1;//signal to new a item
}
void CSetProxyDlg::OnButton1Update()
{
// TODO: Add your control notification handler code here
ExpandDialog(TRUE);
CString btntitle;
GetDlgItemText(IDC_BUTTON_UPDATE1,btntitle);
SetDlgItemText(IDC_BUTTON_ACTION1,btntitle);
POSITION pos = m_listctrl.GetFirstSelectedItemPosition();
if(!pos)
return;
int index=m_listctrl.GetNextSelectedItem(pos);
m_titlectrl.SetWindowText(m_listctrl.GetItemText(index,0));
m_urlctrl.SetWindowText(m_listctrl.GetItemText(index,1));
m_portctrl.SetWindowText(m_listctrl.GetItemText(index,2));
m_action=3;
}
void CSetProxyDlg::OnButtonCancel1()
{
// TODO: Add your control notification handler code here
ExpandDialog(FALSE);
}
void CSetProxyDlg::ExpandDialog(bool expn)
{
CRect rect;
GetWindowRect(rect);
if(expn)
{
if(rect.Height()<m_rectExpn.Height())
{
rect.right=rect.left+m_rectExpn.Width();
rect.bottom=rect.top+m_rectExpn.Height();
MoveWindow(rect);
}
}
else
{
if(rect.Height()>m_rectColp.Height())
{
rect.bottom=rect.bottom-m_rectColp.Height();
MoveWindow(rect);
}
}
}
BOOL CSetProxyDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
GetWindowRect(m_rectExpn);
CWnd *wnd=GetDlgItem(IDC_STATIC_EXPN1);
if(wnd)
wnd->GetWindowRect(m_rectColp);
m_rectColp.bottom=m_rectExpn.bottom;
ExpandDialog(FALSE);
m_listctrl.InsertColumn(0,"",LVCFMT_LEFT,80);
m_listctrl.InsertColumn(1,"",LVCFMT_LEFT,200);
m_listctrl.InsertColumn(2,"",LVCFMT_LEFT,30);
CString url,urlname,urlport;
for(int i=0;i<m_urllist.GetCount();i++)
{
url=m_urllist.GetAt(m_urllist.FindIndex(i));
urlport=url.Mid(url.Find(':')+1);
url=url.Left(url.Find(':'));
m_listctrl.InsertItem(i,url.Left(url.Find('=')));
m_listctrl.SetItem(i,1,LVIF_TEXT,url.Mid(url.Find('=')+1),0,0,0,0);
m_listctrl.SetItem(i,2,LVIF_TEXT,urlport,0,0,0,0);
}
SetLanguage();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CSetProxyDlg::SetUrlListData(CStringList *Url)
{
for(int i=0;i<Url->GetCount();i++)
{
m_urllist.AddTail(Url->GetAt(Url->FindIndex(i)));
}
}
void CSetProxyDlg::OnClose()
{
// TODO: Add your message handler code here and/or call default
m_urllist.RemoveAll();
CDialog::OnClose();
}
void CSetProxyDlg::OnOK()
{
// TODO: Add extra validation here
CString wholeurl;
m_urllist.RemoveAll();
for(int i=0;i<m_listctrl.GetItemCount();i++)
{
wholeurl=m_listctrl.GetItemText(i,0)+"=";
wholeurl+=m_listctrl.GetItemText(i,1)+":";
wholeurl+=m_listctrl.GetItemText(i,2);
m_urllist.AddTail(wholeurl);
}
CDialog::OnOK();
}
void CSetProxyDlg::SetLanguage()
{
CString wintextsrc;
CString wintextnew;
if(this)
{
this->GetWindowText(wintextsrc);
GetText(wintextsrc,wintextnew,global_item_text);
this->SetWindowText(wintextnew);
}
CWnd *wnd=GetDlgItem(IDOK);
if(wnd)
{
wnd->GetWindowText(wintextsrc);
GetText(wintextsrc,wintextnew,global_item_text);
wnd->SetWindowText(wintextnew);
}
wnd=GetDlgItem(IDCANCEL);
if(wnd)
{
wnd->GetWindowText(wintextsrc);
GetText(wintextsrc,wintextnew,global_item_text);
wnd->SetWindowText(wintextnew);
}
wnd=GetDlgItem(IDC_BUTTON_INSERT1);
if(wnd)
{
wnd->GetWindowText(wintextsrc);
GetText(wintextsrc,wintextnew,global_item_text);
wnd->SetWindowText(wintextnew);
}
wnd=GetDlgItem(IDC_BUTTON_UPDATE1);
if(wnd)
{
wnd->GetWindowText(wintextsrc);
GetText(wintextsrc,wintextnew,global_item_text);
wnd->SetWindowText(wintextnew);
}
wnd=GetDlgItem(IDC_BUTTON_DELETE1);
if(wnd)
{
wnd->GetWindowText(wintextsrc);
GetText(wintextsrc,wintextnew,global_item_text);
wnd->SetWindowText(wintextnew);
}
wnd=GetDlgItem(IDC_STATIC_TITLE1);
if(wnd)
{
wnd->GetWindowText(wintextsrc);
GetText(wintextsrc,wintextnew,global_item_text);
wnd->SetWindowText(wintextnew);
}
wnd=GetDlgItem(IDC_STATIC_URL1);
if(wnd)
{
wnd->GetWindowText(wintextsrc);
GetText(wintextsrc,wintextnew,global_item_text);
wnd->SetWindowText(wintextnew);
}
wnd=GetDlgItem(IDC_BUTTON_CANCEL1);
if(wnd)
{
wnd->GetWindowText(wintextsrc);
GetText(wintextsrc,wintextnew,global_item_text);
wnd->SetWindowText(wintextnew);
}
wnd=GetDlgItem(IDC_STATIC_PORT1);
if(wnd)
{
wnd->GetWindowText(wintextsrc);
GetText(wintextsrc,wintextnew,global_item_text);
wnd->SetWindowText(wintextnew);
}
wnd=GetDlgItem(IDC_CHECK_LOCAL);
if(wnd)
{
wnd->GetWindowText(wintextsrc);
GetText(wintextsrc,wintextnew,global_item_text);
wnd->SetWindowText(wintextnew);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -