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

📄 mypropertypage1.cpp

📁 科大通讯录~可以输入、修改通讯录中的数据
💻 CPP
字号:
// MyPropertyPage1.cpp : implementation file
//

#include "stdafx.h"
#include "resource.h"
#include "MyPropertyPage1.h"

#include "EX5_1Doc.h"

#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif

IMPLEMENT_DYNCREATE(CMyPropertyPage1, CPropertyPage)
IMPLEMENT_DYNCREATE(CMyPropertyPage2, CPropertyPage)
IMPLEMENT_DYNCREATE(CMyPropertyPage3, CPropertyPage)


/////////////////////////////////////////////////////////////////////////////
// CMyPropertyPage1 property page

CMyPropertyPage1::CMyPropertyPage1() : CPropertyPage(CMyPropertyPage1::IDD)
{
	//{{AFX_DATA_INIT(CMyPropertyPage1)
	m_Name = _T("");
	m_Address = _T("");
	m_Email = _T("");
	m_Phone = _T("");
	m_UnitValue = _T("");
	//}}AFX_DATA_INIT
}

CMyPropertyPage1::~CMyPropertyPage1()
{
}

void CMyPropertyPage1::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMyPropertyPage1)
	DDX_Control(pDX, IDC_LIST1, m_Unit);
	DDX_Text(pDX, IDC_EDIT1, m_Name);
	DDX_Text(pDX, IDC_EDIT2, m_Address);
	DDX_Text(pDX, IDC_EDIT4, m_Email);
	DDX_Text(pDX, IDC_EDIT3, m_Phone);
	DDX_LBString(pDX, IDC_LIST1, m_UnitValue);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CMyPropertyPage1, CPropertyPage)
	//{{AFX_MSG_MAP(CMyPropertyPage1)
	ON_COMMAND(ID_PROPERTY_DIALOG, OnPropertyDialog)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CMyPropertyPage2 property page

CMyPropertyPage2::CMyPropertyPage2() : CPropertyPage(CMyPropertyPage2::IDD)
{
	//{{AFX_DATA_INIT(CMyPropertyPage2)
	m_NAME_EDIT = _T("");
	m_UNIT_EDIT = _T("");
	m_ADDRESS_EDIT = _T("");
	m_PHONE_EDIT = _T("");
	m_EMAIL_EDIT = _T("");
	//}}AFX_DATA_INIT
}

CMyPropertyPage2::~CMyPropertyPage2()
{
}

void CMyPropertyPage2::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMyPropertyPage2)
	DDX_Control(pDX, IDC_LIST1, m_NAME_LIST);
	DDX_Text(pDX, IDC_EDIT1, m_NAME_EDIT);
	DDX_Text(pDX, IDC_EDIT2, m_UNIT_EDIT);
	DDX_Text(pDX, IDC_EDIT3, m_ADDRESS_EDIT);
	DDX_Text(pDX, IDC_EDIT4, m_PHONE_EDIT);
	DDX_Text(pDX, IDC_EDIT5, m_EMAIL_EDIT);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CMyPropertyPage2, CPropertyPage)
	//{{AFX_MSG_MAP(CMyPropertyPage2)
	ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
	ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
	ON_LBN_SELCHANGE(IDC_LIST1, OnSelchangeList1)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CMyPropertyPage3 property page

CMyPropertyPage3::CMyPropertyPage3() : CPropertyPage(CMyPropertyPage3::IDD)
{
	//{{AFX_DATA_INIT(CMyPropertyPage3)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}

CMyPropertyPage3::~CMyPropertyPage3()
{
}

void CMyPropertyPage3::DoDataExchange(CDataExchange* pDX)
{
	CPropertyPage::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMyPropertyPage3)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CMyPropertyPage3, CPropertyPage)
	//{{AFX_MSG_MAP(CMyPropertyPage3)
		// NOTE: the ClassWizard will add message map macros here
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()



void CMyPropertyPage1::OnPropertyDialog() 
{
	// TODO: Add your command handler code here

}

BOOL CMyPropertyPage1::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();
	
	// TODO: Add extra initialization here
	fontText.CreateFont(16,10,-10,0,0,FALSE,FALSE,FALSE,DEFAULT_CHARSET,
		OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,DEFAULT_QUALITY,
		DEFAULT_PITCH|FF_SWISS,"隶书");
	m_Unit.SetFont(&fontText,TRUE);
	m_Unit.AddString("电子技术学院");
    m_Unit.AddString("化学工程学院");
    m_Unit.AddString("环境工程学院");
    m_Unit.AddString("材料工程学院");
    m_Unit.AddString("网络工程学院");
    m_Unit.AddString("生物工程学院");
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CMyPropertyPage1::OnButton1() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	if(!m_Name.IsEmpty())
	{
		int m_Index;
		CFrameWnd* pMain=(CFrameWnd*)AfxGetApp()->m_pMainWnd;
		CEX5_1Doc* pDoc=(CEX5_1Doc*)pMain->GetActiveDocument();
		CAddressList* pList;
		pList=new CAddressList(m_Name,m_UnitValue,m_Address,m_Phone,m_Email);
		m_Index=pDoc->m_AddressList.Add(pList);
		SetDlgItemInt(IDC_EDIT5,m_Index+1,TRUE);
	}
	else
	{
		MessageBox("你没有输入姓名","警告!",1);
	}
	}

void CMyPropertyPage2::OnButton1() 
{
	// TODO: Add your control notification handler code here
    CFrameWnd* pMain=(CFrameWnd*)AfxGetApp()->m_pMainWnd;
    CEX5_1Doc* pDoc=(CEX5_1Doc*)pMain->GetActiveDocument();
	CAddressList* pList;
	int Counter=pDoc->m_AddressList.GetSize();
	for(int i=0;i<Counter;i++)
	{
		pList=pDoc->m_AddressList.GetAt(i);
        m_NAME_LIST.AddString(pList->m_Name);
	}	
}

void CMyPropertyPage2::OnButton2() 
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	if(!m_NAME_EDIT.IsEmpty())
	{
		CFrameWnd* pMain=(CFrameWnd*)AfxGetApp()->m_pMainWnd;
		CEX5_1Doc* pDoc=(CEX5_1Doc*)pMain->GetActiveDocument();
		CAddressList* pList=new CAddressList(m_NAME_EDIT,m_UNIT_EDIT,m_ADDRESS_EDIT,
			m_PHONE_EDIT,m_EMAIL_EDIT);
		pDoc->m_AddressList.SetAt(m_Index,pList);
	}
	else
	{
		MessageBox("你没有选择姓名!","警告!",1);
	}	
}

void CMyPropertyPage2::OnSelchangeList1() 
{
	// TODO: Add your control notification handler code here
    CString temp;
	int SelPosition=m_NAME_LIST.GetCurSel();
	m_NAME_LIST.GetText(SelPosition,temp);
	CFrameWnd* pMain=(CFrameWnd*)AfxGetApp()->m_pMainWnd;
    CEX5_1Doc* pDoc=(CEX5_1Doc*)pMain->GetActiveDocument();
	CAddressList* pList;
    int Counter=pDoc->m_AddressList.GetSize();
	for(int i=0;i<Counter;i++)
	{
		pList=pDoc->m_AddressList.GetAt(i);
		if(temp==pList->m_Name)
		{
			m_NAME_EDIT=pList->m_Name;
				m_UNIT_EDIT=pList->m_Unit;
				m_ADDRESS_EDIT=pList->m_Address;
				m_PHONE_EDIT=pList->m_Phone;
				m_EMAIL_EDIT=pList->m_Email;
				m_Index=i;
				UpdateData(FALSE);
		}
	}	
}

⌨️ 快捷键说明

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