void CADOTest1Dlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
void CADOTest1Dlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
HCURSOR CADOTest1Dlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CADOTest1Dlg::OnOK()
{
if(m_bSuccess)
{
m_pRecordset->Update();
m_pRecordset->Close();
}
CDialog::OnOK();
}
void CADOTest1Dlg::OnAdditem()
{
if(UpdateData())
if(m_sUsername.GetLength()>0)
{
m_pRecordset->AddNew();
m_nCurrentSel = m_userlist.InsertItem(0xffff,"");
SaveData();///保存数据
m_userlist.SetItemState(m_nCurrentSel,LVIS_SELECTED|LVIS_FOCUSED,LVIS_SELECTED|LVIS_FOCUSED);
m_userlist.SetHotItem(m_nCurrentSel);
m_userlist.SetFocus();
}
else
AfxMessageBox("请输入用户名");
}
void CADOTest1Dlg::OnDelitem()
{
m_bAutoSave = FA