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

📄 sysoptionpage.cpp

📁 非常好用的VC++源代码
💻 CPP
字号:
// SysOptionPage.cpp : implementation file
//

#include "stdafx.h"
#include "Toller.h"
#include "SysOptionPage.h"
#include "MainFrm.h"

#include "addsuffixdlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CSysOptionPage property page

IMPLEMENT_DYNCREATE(CSysOptionPage, CPropertyPage)

CSysOptionPage::CSysOptionPage() : CPropertyPage(CSysOptionPage::IDD)
{
	//{{AFX_DATA_INIT(CSysOptionPage)
	m_sPrefix = _T("");
	//}}AFX_DATA_INIT
}

CSysOptionPage::~CSysOptionPage()
{
}

void CSysOptionPage::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CSysOptionPage)
	DDX_Control(pDX, IDC_PREFIX_LIST, m_listPrefix);
	DDX_Text(pDX, IDC_PREFIX_EDIT, m_sPrefix);
	DDV_MaxChars(pDX, m_sPrefix, 15);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CSysOptionPage, CPropertyPage)
	//{{AFX_MSG_MAP(CSysOptionPage)
	ON_BN_CLICKED(IDC_BTN_ADD, OnBtnAdd)
	ON_BN_CLICKED(IDC_BTN_DELETE, OnBtnDelete)
	ON_BN_CLICKED(IDC_ADD_SUFFIX, OnAddSuffix)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CSysOptionPage message handlers

void CSysOptionPage::OnBtnAdd() 
{
	// TODO: Add your control notification handler code here
	UpdateData();
	if(m_listPrefix.FindString(0,m_sPrefix)!=LB_ERR)return;//find the string in the list
	m_listPrefix.AddString(m_sPrefix);
}

void CSysOptionPage::OnBtnDelete() 
{
	// TODO: Add your control notification handler code here
	int nIndex=m_listPrefix.GetCurSel();

	if((m_listPrefix.GetCount())!=0)
	{
		m_listPrefix.DeleteString(nIndex);
	}
	//then select the next string
	if((m_listPrefix.GetCount())!=0)
	{
		if(nIndex>m_listPrefix.GetCount()-1)//is the last item
		{
			nIndex=0;
		}
		m_listPrefix.SetCurSel(nIndex);
	}

}

void CSysOptionPage::OnOK() 
{
	// TODO: Add your specialized code here and/or call the base class
	// save the usernames to the CERNIPPrefixList
	CMainFrame* pFrame=(CMainFrame*)AfxGetMainWnd();

	pFrame->CERNIPPrefixList.RemoveAll();

	CString item;

	int nCount=m_listPrefix.GetCount();

	for(int i=0;i<nCount;i++)
	{
		m_listPrefix.GetText(i,item);
		pFrame->CERNIPPrefixList.AddTail(CString(item));
	}


	CPropertyPage::OnOK();
}

BOOL CSysOptionPage::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();
	
	// TODO: Add extra initialization here
	//fill the listbox with the specialuselist
	CMainFrame* pFrame=(CMainFrame*)AfxGetMainWnd();
	
	CString item;
	POSITION pos;

	m_listPrefix.ResetContent();

	if((pos=pFrame->CERNIPPrefixList.GetHeadPosition())!=NULL)
	{
	/*
		item=(pFrame->CERNIPPrefixList).GetAt(pos);
		m_listPrefix.AddString(item);	
	*/
		while(pos!=NULL)
		{
			item=(pFrame->CERNIPPrefixList).GetNext(pos);
			m_listPrefix.AddString(item);	
		}
	}

	m_listPrefix.SetCurSel(0);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CSysOptionPage::OnAddSuffix() 
{
	// TODO: Add your control notification handler code here
	CAddSuffixDlg dialog;
	dialog.DoModal();
}

⌨️ 快捷键说明

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