⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 setaliasdlg.cpp

📁 1.MyIE开源工程协议 MyIE开源工程遵循GNU通用公共许可证GPL(GNU General Public License)开发,任何人都可以永久免费安装使用,在你下载和使用MyIE源代码前,请
💻 CPP
字号:
// SetAliasDlg.cpp : implementation file
//

#include "stdafx.h"
#include "MyIE.h"
#include "SetAliasDlg.h"
#include "InputAlias.h"
#include "MainFrm.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


//#pragma optimize( "s", on )

/////////////////////////////////////////////////////////////////////////////
// CSetAliasDlg dialog


CSetAliasDlg::CSetAliasDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CSetAliasDlg::IDD, pParent)
{
	//{{AFX_DATA_INIT(CSetAliasDlg)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CSetAliasDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSetAliasDlg)
	DDX_Control(pDX, IDC_LIST1, m_list);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSetAliasDlg, CDialog)
	//{{AFX_MSG_MAP(CSetAliasDlg)
	ON_BN_CLICKED(IDC_NEW, OnNew)
	ON_BN_CLICKED(IDC_UPDATE, OnUpdate)
	ON_BN_CLICKED(IDC_DEL, OnDel)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSetAliasDlg message handlers

BOOL CSetAliasDlg::OnInitDialog() 
{
	LOADDLG("DialogAlias");
	CDialog::OnInitDialog();

	m_list.SetExtendedStyle(m_list.GetExtendedStyle()| LVS_EX_FULLROWSELECT);
	// TODO: Add extra initialization here
	CRect rect;
	CString str;
	LOADSTR(str ,IDS_ALIAS);
	m_list.InsertColumn(0,str);
	m_list.GetWindowRect(rect);
	m_list.SetColumnWidth(0, 60);
	LOADSTR(str ,IDS_URL);
	m_list.InsertColumn(1,str);
	m_list.SetColumnWidth(1, rect.Width()-78);

	POSITION pos = pmf->m_mapAlias.GetStartPosition();
	CString alias, url;
	int i=0;
	while(pos!=NULL)
	{
		pmf->m_mapAlias.GetNextAssoc(pos, alias, url);
		m_list.InsertItem(i, alias);
		m_list.SetItemText(i, 1, url);
		i++;
	}
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CSetAliasDlg::OnOK() 
{
	// TODO: Add extra validation here
	pmf->m_mapAlias.RemoveAll();
	int n = m_list.GetItemCount();
	CString alias;
	for( int i=0; i<n; i++)
	{
		alias = m_list.GetItemText(i,0);
		alias.TrimLeft(); alias.TrimRight();
		pmf->m_mapAlias.SetAt(alias,m_list.GetItemText(i,1));
	}
	
	CDialog::OnOK();
}

void CSetAliasDlg::OnNew() 
{
	// TODO: Add your control notification handler code here
	CInputAlias dlg;
	if(dlg.DoModal() == IDOK)
	{
		CString alias = dlg.m_alias;
		CString url = dlg.m_url;
		alias.TrimLeft();
		url.TrimLeft();
		int i = m_list.GetItemCount();
		if(alias !="" && !alias.IsEmpty() && url!="" && !url.IsEmpty())
		{
			m_list.InsertItem(i, alias);
			m_list.SetItemText(i, 1, url);
		}
	}
}

void CSetAliasDlg::OnUpdate() 
{
	// TODO: Add your control notification handler code here
	POSITION pos = m_list.GetFirstSelectedItemPosition();
	if(pos!=NULL)
	{
		int i = m_list.GetNextSelectedItem(pos);
		CInputAlias dlg;
		dlg.m_alias = m_list.GetItemText(i,0);
		dlg.m_url = m_list.GetItemText(i,1);
		if(dlg.DoModal() == IDOK)
		{
			CString alias = dlg.m_alias;
			CString url = dlg.m_url;
			alias.TrimLeft();
			url.TrimLeft();
			if(alias !="" && !alias.IsEmpty() && url!="" && !url.IsEmpty())
			{
				m_list.SetItemText(i, 0, alias);
				m_list.SetItemText(i, 1, url);
			}
		}
	}
}

void CSetAliasDlg::OnDel() 
{
	// TODO: Add your control notification handler code here
	POSITION pos = m_list.GetFirstSelectedItemPosition();
	if(pos!=NULL)
	{
		int i = m_list.GetNextSelectedItem(pos);
		m_list.DeleteItem(i);
		//
		LIST_FOCUS_POS(m_list,i);
	}	
}

//#pragma optimize( "s", off )

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -