emMetrics(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();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CMy724Dlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CMy724Dlg::OnQueryBtn()
{
// TODO: Add your control notification handler code here
_variant_t var;
CString strName,strBirthday,strID;
CString strSQL;
m_pRecordset.CreateInstance("ADODB.Recordset");
strSQL="select * from employee where Birthday=#1960-5-29#"; //*******
m_pRecordset->Open((_variant_t)strSQL,_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText);
if (FAILED(m_pRecordset.CreateInstance("ADODB.Recordset")))
{
AfxMessageBox("Create Instance failed!");
return;
}
if (FAILED(m_pRecordset->Open((_variant_t)strSQL,_variant_t((IDispatch*)theApp.m_pConnection,true),adOpenStatic,adLockOptimistic,adCmdText)))
{
AfxMessageBox("Can not open Database!");
return;
}
while(!m_pRecordset->adoEOF)//将查询到的数据加到列表框
{
var =(_bstr_t)m_pRecordset->GetCollect("ID");
if(var.vt != VT_NULL)
strID =(LPCSTR)_bstr_t(var);
var = (_bstr_t)m_pRecordset->GetCollect("Name");
if(var.vt != VT_NULL)
strName = (LPCSTR)_bstr_t(var);
var = (_bstr_t)m_pRecordset->GetCollect("Birthday");
if(var.vt != VT_NULL)
strBirthday = (LPCSTR)_bstr_t(var);
// ((CListBox*)GetDlgItem(IDC_LIST1))->SetHorizontalExtent(1000); //*****
((CListBox*)GetDlgItem(IDC_LIST1))->AddString(strID+"—"+strName+"—"+strBirthday);
m_pRecordset->MoveNext();
}
}