void CDialogList::OnBnClickedButton1()
{
// TODO: 在此添加控件通知处理程序代码
CString text;
m_Edit.GetWindowText(text);
if(text.IsEmpty())
{
MessageBox(_T("不能为空"));
return;
}
//m_List.AddString(text);
m_List.InsertString(m_List.GetCount(),text);
m_Edit.SetWindowText(_T(""));
m_Edit.SetFocus();
}
void CDialogList::OnBnClickedButton2()
{
// TODO: 在此添加控件通知处理程序代码
int pos = m_List.GetCurSel();
if(pos < 0)
{
MessageBox(_T("请选择要删除的列表项"));
return;
}
m_List.DeleteString(pos);
}
void CDialogList::OnBnClickedButton3()
{
// TODO: 在此添加控件通知处理程序代码
int pos = m_List.GetCurSel();
if(pos < 0)
{
MessageBox(_T("请选择要上移的列表项"));
return;
}
if(0 == pos)
{
MessageBox(_T("已经是第一项"));
return;
}
CString text;
m_List.GetText(pos,text);
m_List.DeleteString(pos);
m_List.InsertString(pos-1,text);
m_List.SetCurSel(pos-1);
}
void CDialogList::OnBnClickedButton4()
{
// TODO: 在此添加控件通知处理程序代码
int pos = m_List.GetCurSel();
if(pos < 0)
{
MessageBox(_T("请选择要下移的列表项"));
return;
}
if(m_List.GetCount() - 1 == pos)
{
MessageBox(_T("已经是第最后一项"));
return;
}
CString text;
m_List.GetText(pos,text);
m_List.DeleteString(pos);
m_List.InsertString(pos+1,text);
m_List.SetCurSel(pos+1);
}
void CDialogList::OnBnClickedButton5()
{
// TODO: 在此添加控件通知处理程序代码
if(m_List.GetCount())
{
m_List.ResetContent();
}
}
void CDialogList::OnBnClickedButton6()
{
// TODO: 在此添加控件通知处理程序代码
CString text;
m_Edit.GetWindowText(text);
if(text.IsEmpty())
{
MessageBox(_T("不能为空"));
return;
}
m_List.SelectString(-1,text);
}