return 0;
}
现在想放到这里了,但是还不行
这是CLogin里的代码:
BOOL CLogin::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CMainFrame* pMain=(CMainFrame*)AfxGetMainWnd();
CChickensDoc* pDoc=(CChickensDoc*)pMain->GetActiveDocument();
pDoc->m_rec->Open("select * from OPERATOR",pDoc->m_con.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);
if(!pDoc->m_rec->BOF)
{
_variant_t var;
CString oper;
pDoc->m_rec->MoveFirst();
while(!pDoc->m_rec->SSTEOF)
{
var=pDoc->m_rec->GetCollect("checkperson");
if(var.vt!=NULL)
{
oper=(LPCSTR)_bstr_t(var);
m_Name.AddString(oper);
}
}
}
else
{
AfxMessageBox("无数据");
return FALSE;
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
只要用到上面的代码就不能执行,说信息丢失
不会啊,我不会弄消息,因为补知道消息是怎么回事.我现在把代码都放到
CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)中了,可还是不行,再这里怎么获得doc指针啊
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
...
CLogin LoginDlg;
int result;
int ok=0;
CMainFrame* pMain=(CMainFrame*)AfxGetMainWnd();
CChickensDoc* pDoc=(CChickensDoc*)pMain->GetActiveDocument();
do{
result=LoginDlg.DoModal();
CString sql;
if(result==IDOK)
{
//登录
sql="select * from OPERATOR where checkperson='"+LoginDlg.m_Name+"'";
BSTR strsql=sql.AllocSysString();
if(pDoc->m_rec->State)
{
pDoc->m_rec->Close();
}
pDoc->m_rec->Open(strsql,pDoc->m_con.GetInterfacePtr(),adOpenDynamic,adLockOptimistic,adCmdText);
if(!pDoc->m_rec->BOF)
{
_variant_t var;
CString pass;
pDoc->m_rec->MoveFirst();
while(!pDoc->m_rec->SSTEOF)
{
var=pDoc->m_rec->GetCollect("password");
if(var.vt!=NULL)
{
pass=(LPCSTR)_bstr_t(var);
}
if(strcmp(pass,LoginDlg.m_Pass)==0)
{
ok=true;
break;
}
pDoc->m_rec->MoveNext();
}
}
}
else
{
//取消
return -1;
}
}while(ok<4);
return 0;
}
可是还事信息丢失,我跟踪执行,是先执行的doc,再执行的frame,(感谢7楼)可怎么还是不行啊
[此贴子已经被作者于2007-5-12 12:18:34编辑过]