好友
阅读权限 10
听众
最后登录 1970-1-1
刚刚才学,所以想请教下,想写一个比如列表用户上线,出现提示音,如图所示。
BOOL CUserDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
m_ImageList.Create(32,32,ILC_COLOR24|ILC_MASK,1,1);
//向图像列表中添加图标
m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_USER));
m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_STORAGE));
m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_SALE));
m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_GOODS));
m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_COUNT));
m_ImageList.Add(AfxGetApp()->LoadIcon(IDI_EXIT));
UINT array[8];
for(int i=0;i<7;i++)
{
if(i==4 || i==6)
array[i] = ID_SEPARATOR; //第3、6个按钮为分隔条
else
array[i] = i+IDUM_USER;
}
array[7] = IDOK;
m_ToolBar.Create(this);
m_ToolBar.SetButtons(array,8);
//关联图像列表
m_ToolBar.GetToolBarCtrl().SetImageList(&m_ImageList);
m_ToolBar.SetSizes(CSize(50,60),CSize(32,32)); //设置按钮和图标的大小
//设置工具栏按钮的显示文本
m_ToolBar.SetButtonText(0,"员工管理");
m_ToolBar.SetButtonText(1,"仓库管理");
m_ToolBar.SetButtonText(2,"票务管理");
m_ToolBar.SetButtonText(3,"商品管理");
m_ToolBar.SetButtonText(5,"营业统计");
m_ToolBar.SetButtonText(7,"退出系统");
RepositionBars(AFX_IDW_CONTROLBAR_FIRST,AFX_IDW_CONTROLBAR_LAST,0);
m_list.SetExtendedStyle(LVS_EX_CHECKBOXES|LVS_EX_FULLROWSELECT|LVS_EX_ONECLICKACTIVATE|LVS_EX_GRIDLINES|
m_list.GetExtendedStyle());
/*m_list.SetExtendedStyle(LVS_EX_FLATSB
|LVS_EX_FULLROWSELECT
|LVS_EX_HEADERDRAGDROP
|LVS_EX_ONECLICKACTIVATE
|LVS_EX_GRIDLINES);*/
m_list.InsertColumn(0,"员工编号",LVCFMT_CENTER,70,1);
m_list.InsertColumn(1,"密码",LVCFMT_CENTER,50,4);
m_list.InsertColumn(2,"权限",LVCFMT_CENTER,38,6);
m_list.InsertColumn(3,"职位",LVCFMT_CENTER,60,5);
m_list.InsertColumn(4,"姓名",LVCFMT_CENTER,57,5);
m_list.InsertColumn(5,"性别",LVCFMT_CENTER,38,1);
m_list.InsertColumn(6,"身份证号",LVCFMT_CENTER,120,1);
m_list.InsertColumn(7,"联系方式",LVCFMT_CENTER,80,1);
m_list.InsertColumn(8,"入职时间",LVCFMT_CENTER,85,1);
m_list.InsertColumn(9,"家庭住址",LVCFMT_CENTER,190,1);
OnSelect() ;
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CUserDlg::OnSelect()
{
// TODO: Add your control notification handler code here
m_list.DeleteAllItems();
CString sql;
int intInfo;
UpdateData(true);
sql.Format("select * from WORKER where WorkerID");
ADOConn adoConn;
adoConn.OnInitADOConn();
adoConn.m_pRecordset = adoConn.GetRecordSet((_bstr_t)sql);
CString workid,name,Permissions,sex,id,phone,address,pwd;
int i = 0;
while(!adoConn.m_pRecordset->adoEOF)
{
m_list.InsertItem(i,"");
m_list.SetItemText(i,0,(char *)(_bstr_t)adoConn.m_pRecordset->GetCollect("WorkerID"));
m_list.SetItemText(i,1,(char *)(_bstr_t)adoConn.m_pRecordset->GetCollect("PWD"));
m_list.SetItemText(i,2,(char *)(_bstr_t)adoConn.m_pRecordset->GetCollect("Permissions"));
m_list.SetItemText(i,3,(char *)(_bstr_t)adoConn.m_pRecordset->GetCollect("WorkerPosition"));
m_list.SetItemText(i,4,(char *)(_bstr_t)adoConn.m_pRecordset->GetCollect("Name"));
CString strSex = (char *)(_bstr_t)adoConn.m_pRecordset->GetCollect("Sex");
int bMan = atoi(strSex);
if(bMan)
m_list.SetItemText(i,5,"男");
else
m_list.SetItemText(i,5,"女");
m_list.SetItemText(i,6,(char *)(_bstr_t)adoConn.m_pRecordset->GetCollect("ID"));
m_list.SetItemText(i,7,(char *)(_bstr_t)adoConn.m_pRecordset->GetCollect("Phone"));
m_list.SetItemText(i,8,(char *)(_bstr_t)adoConn.m_pRecordset->GetCollect("StartTime"));
m_list.SetItemText(i,9,(char *)(_bstr_t)adoConn.m_pRecordset->GetCollect("Address"));
adoConn.m_pRecordset->MoveNext();
}
}