📄 userlistdlg.cpp
字号:
// UserListDlg.cpp : implementation file
//
#include "stdafx.h"
#include "Toller.h"
#include "UserListDlg.h"
#include "MainFrm.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CUserListDlg dialog
CUserListDlg::CUserListDlg(CWnd* pParent /*=NULL*/)
: CDialog(CUserListDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CUserListDlg)
m_sUser = _T("");
//}}AFX_DATA_INIT
}
void CUserListDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CUserListDlg)
DDX_Control(pDX, IDC_USERLIST, m_listUser);
DDX_Text(pDX, IDC_USEREDIT, m_sUser);
DDV_MaxChars(pDX, m_sUser, 6);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CUserListDlg, CDialog)
//{{AFX_MSG_MAP(CUserListDlg)
ON_BN_CLICKED(IDC_BTNADD, OnBtnadd)
ON_BN_CLICKED(IDC_BTNDELETE, OnBtndelete)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CUserListDlg message handlers
void CUserListDlg::OnBtnadd()
{
// TODO: Add your control notification handler code here
UpdateData();
if(m_listUser.FindString(0,m_sUser)!=LB_ERR)return;
m_listUser.AddString(m_sUser);
m_sUser="";
UpdateData(FALSE);
GetDlgItem(IDC_USEREDIT)->SetFocus();;
}
void CUserListDlg::OnBtndelete()
{
// TODO: Add your control notification handler code here
int nIndex=m_listUser.GetCurSel();
if((m_listUser.GetCount())!=0)
{
m_listUser.DeleteString(nIndex);
}
//then select the next string
if((m_listUser.GetCount())!=0)
{
if(nIndex>m_listUser.GetCount()-1)//is the last item
{
nIndex=0;
}
m_listUser.SetCurSel(nIndex);
}
}
BOOL CUserListDlg::OnInitDialog()
{
CDialog::OnInitDialog();
//fill the listbox with the specialuselist
CMainFrame* pFrame=(CMainFrame*)AfxGetMainWnd();
CString item;
POSITION pos;
m_listUser.ResetContent();
if((pos=pFrame->SpecialUserList.GetHeadPosition())!=NULL)
{
/*
item=(pFrame->SpecialUserList).GetAt(pos);
m_listUser.AddString(item);
*/
while(pos!=NULL)
{
item=(pFrame->SpecialUserList).GetNext(pos);
m_listUser.AddString(item);
}
}
m_listUser.SetCurSel(0);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CUserListDlg::OnOK()
{
// save the usernames to the SpecialUserList
CMainFrame* pFrame=(CMainFrame*)AfxGetMainWnd();
pFrame->SpecialUserList.RemoveAll();
CString item;
int nCount=m_listUser.GetCount();
for(int i=0;i<nCount;i++)
{
m_listUser.GetText(i,item);
pFrame->SpecialUserList.AddTail(CString(item));
}
CDialog::OnOK();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -