📄 dlgblockurl.cpp
字号:
// DlgBlockUrl.cpp : implementation file
//
#include "stdafx.h"
#include "LeoBlock2004.h"
#include "DlgBlockUrl.h"
#include "LRegistry.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CDlgBlockUrl dialog
CDlgBlockUrl::CDlgBlockUrl(CWnd* pParent /*=NULL*/)
: CDialog(CDlgBlockUrl::IDD, pParent)
{
//{{AFX_DATA_INIT(CDlgBlockUrl)
//}}AFX_DATA_INIT
nCount=0;
}
void CDlgBlockUrl::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CDlgBlockUrl)
DDX_Control(pDX, IDOK, m_buOk);
DDX_Control(pDX, IDC_BUTTON_DEL_ALL, m_buDelAll);
DDX_Control(pDX, IDC_BUTTON_DEL, m_buDel);
DDX_Control(pDX, IDC_BUTTON_ADD, m_buAdd);
DDX_Control(pDX, IDC_COMBO3, m_BlockUrlCom);
DDX_Control(pDX, IDC_LIST_URL, m_BlockUrlList);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CDlgBlockUrl, CDialog)
//{{AFX_MSG_MAP(CDlgBlockUrl)
ON_BN_CLICKED(IDC_BUTTON_ADD, OnButtonAdd)
ON_BN_CLICKED(IDC_BUTTON_DEL, OnButtonDel)
ON_BN_CLICKED(IDC_BUTTON_DEL_ALL, OnButtonDelAll)
ON_NOTIFY(NM_CLICK, IDC_LIST_URL, OnClickListUrl)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CDlgBlockUrl message handlers
BOOL CDlgBlockUrl::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
//如果注册表键没有创建,就创建一个键
CLRegistry m_DlgRegistry;
HKEY nhKeyRoot=HKEY_CURRENT_USER;
LPSTR nszKeyPath="Software\\BLeo2004";
LPSTR nszS1KeyPath="Software\\BLeo2004\\BlockUrl";
if(m_DlgRegistry.Open(nhKeyRoot,nszS1KeyPath))
{
DWORD nindex=0;
int nIndex=0;
CString nsKey; //注册表键"Url0"
CString szValue; //注册表键"Url0"的值"xxx.xx.xx"
while(m_DlgRegistry.EnumValueA(nsKey,szValue,nindex))
{
m_DlgRegistry.Read((LPCTSTR)nsKey,szValue);
if(szValue.GetLength()>0)
m_BlockUrlList.InsertItem(nIndex,szValue);
nindex++;
nIndex++;
nsKey="";
szValue="";
}
}
m_DlgRegistry.Close();
//在ListCtrl中加入报表头
LV_COLUMN nlistColumn;
LPTSTR urlHead="网址";
nlistColumn.mask=LVCF_FMT|LVCF_WIDTH|LVCF_TEXT|LVCF_SUBITEM;
nlistColumn.fmt=LVCFMT_LEFT;
nlistColumn.iSubItem=0;
nlistColumn.cx=283;
nlistColumn.pszText=urlHead;
m_BlockUrlList.InsertColumn(0,&nlistColumn);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDlgBlockUrl::OnButtonAdd()
{
// TODO: Add your control notification handler code here
//加入的字符串全部为小写
LEO_DLGURLINFO nUrlInfo;
CString nStr;
int nIndex=0;
UpdateData();
m_BlockUrlCom.GetWindowText(nStr);
if(nStr.GetLength()>0)
{
nStr.MakeLower();
nCount=m_BlockUrlList.GetItemCount();
nIndex=nCount;
m_BlockUrlList.InsertItem(nIndex,(LPCTSTR)nStr);
nUrlInfo.index=nIndex;
nUrlInfo.str=(LPCTSTR)nStr;
m_BlockUrlCom.SetWindowText("");
AfxGetApp()->GetMainWnd()->SendMessage(LEO_DLGURLLISTADD,0,(LPARAM)&nUrlInfo);
}
UpdateData(FALSE);
}
void CDlgBlockUrl::OnButtonDel()
{
// TODO: Add your control notification handler code here
LEO_DLGURLINFO nUrlInfo;
int nChoice;
int nindex=m_BlockUrlList.GetNextItem(-1,LVNI_SELECTED);
nUrlInfo.index=nindex;
nChoice=MessageBox("要删除选中的网址","Leo",MB_YESNO|MB_ICONQUESTION);
if(nChoice==IDYES)
{
m_BlockUrlList.DeleteItem(nindex);
AfxGetApp()->GetMainWnd()->SendMessage(LEO_DLGURLLISTDEL,0,(LPARAM)&nUrlInfo);
}
}
void CDlgBlockUrl::OnButtonDelAll()
{
// TODO: Add your control notification handler code here
int nChoice=MessageBox("要删除全部网址","Leo",MB_YESNO|MB_ICONQUESTION);
if(nChoice==IDYES)
{
m_BlockUrlList.DeleteAllItems();
AfxGetApp()->GetMainWnd()->SendMessage(LEO_DLGURLLISTDELALL,1,0);
}
}
void CDlgBlockUrl::OnClickListUrl(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
*pResult = 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -