不会啊,我不会弄消息,因为补知道消息是怎么回事.我现在把代码都放到
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编辑过]