📄 textlistbox.cpp
字号:
// TextListBox.cpp : implementation file
//
#include "stdafx.h"
#include "CTestListBoxDlg.h"
#include "TextListBox.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// TextListBox
IMPLEMENT_DYNCREATE(TextListBox, CFormView)
TextListBox::TextListBox()
: CFormView(TextListBox::IDD)
{
//{{AFX_DATA_INIT(TextListBox)
m_Name = _T("");
m_Tel = _T("");
m_Postc = _T("");
m_Addr = _T("");
//}}AFX_DATA_INIT
}
TextListBox::~TextListBox()
{
}
void TextListBox::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
//{{AFX_DATA_MAP(TextListBox)
DDX_Control(pDX, IDC_LIST1, m_List);
DDX_Text(pDX, IDC_name, m_Name);
DDV_MaxChars(pDX, m_Name, 10);
DDX_Text(pDX, IDC_tel, m_Tel);
DDV_MaxChars(pDX, m_Tel, 10);
DDX_Text(pDX, IDC_postc, m_Postc);
DDV_MaxChars(pDX, m_Postc, 10);
DDX_Text(pDX, IDC_add, m_Addr);
DDV_MaxChars(pDX, m_Addr, 10);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(TextListBox, CFormView)
//{{AFX_MSG_MAP(TextListBox)
ON_BN_CLICKED(IDC_addata, Onaddata)
ON_BN_CLICKED(IDC_exit, Onexit)
ON_LBN_SELCHANGE(IDC_LIST1, OnSelchangeList1)
ON_WM_DESTROY()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// TextListBox diagnostics
#ifdef _DEBUG
void TextListBox::AssertValid() const
{
CFormView::AssertValid();
}
void TextListBox::Dump(CDumpContext& dc) const
{
CFormView::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// TextListBox message handlers
void TextListBox::Onaddata()
{
UpdateData(TRUE);
m_Name.TrimLeft();
m_Name.TrimRight();
int nIndex=m_List.AddString(m_Name);
ZGREC data;
data.Tel=m_Tel;
data.Postc=m_Postc;
data.Addr=m_Addr;
// TODO: Add your control notification handler code here
}
void TextListBox::Onexit()
{
// TODO: Add your control notification handler code here
}
void TextListBox::OnSelchangeList1()
{
int nIndex=m_List.GetCurSel();
if(nIndex!=LB_ERR)
{m_List.GetText(nIndex,m_Name);
ZGREC*data=(ZGREC*)m_List.GetItemDataPtr(nIndex);
m_Tel=data->Tel;
m_Postc=data->Postc;
m_Addr=data->Addr;
UpdateData(FALSE);
// TODO: Add your control notification handler code here
}
}
void TextListBox::OnDestroy()
{
for(int nIndex=m_List.GetCount()-1;nIndex>=0;nIndex--)
{delete(ZGREC*)m_List.GetItemDataPtr(nIndex);
}
CFormView::OnDestroy();
// TODO: Add your message handler code here
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -