20秒扫描一次数据库,频率也不是很高啊
而且记录条也才10条左右,处理完后就删除
SetTimer(1,20000,NULL);
有什么解决办法啊??void CMainFrame::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
CInfoView *p_view= (CInfoView*)_GET_CLASS(RUNTIME_CLASS(CInfoView));
if(nIDEvent==1)
p_view->ReadDb();//扫描数据库
else if(nIDEvent==2)
p_view->ScanPorts();
CXTFrameWnd::OnTimer(nIDEvent);}
void readdb()
{
CAdoRsValues rsv;
CString strSQL;
CString zylx;
CString zydm;
int zylxdm;
if (m_nRead==0)
m_nRead=1;
else
return;
strSQL="select * from lcxx order by lsh";
_IF_DB_ERROR_EXIT(lcjfAfxData.m_adoDBConn.OpenAdoRsValues(strSQL,&rsv));
int i=1;
CString to_enter_rail;
while(!rsv.IsEndOfFile())
{
CAdoRsValues rsv1;
CString strSQL1;
CString zydm;
CString xh;
CString Rail;
xh.Format("%d",nMessage_In_Grid);
//上行要牌
if(!rsv.GetItemStr("leave_fact_time").IsEmpty()&&(rsv.GetItemStr("node_name")==theApp.UpwardYgz||rsv.GetItemStr("node_name")==theApp.UpwardYgz2)&&lcjfAfxData.GetTrainDirection(rsv.GetItemStr("leave_train_name")))
{
if(rsv.GetItemStr("leave_train_name").GetLength()>=5)
zylx="上行货车要牌";
else
zylx="上行客车要牌";
DlgTrainBlock dlg;
dlg.m_sTrain=rsv.GetItemStr("leave_train_name");
sndPlaySound(SOUND_NOTIFY,SND_ASYNC);
Sleep(1000);
sndPlaySound(SOUND_NOTIFY,SND_ASYNC);
Sleep(1000);
sndPlaySound(SOUND_NOTIFY,SND_ASYNC);
Sleep(1000);
if(dlg.DoModal()==IDOK)
{
Rail=dlg.m_sRail;
m_pGridCtrl->SetItemText(nMessage_In_Grid,0,xh);
m_pGridCtrl->SetItemText(nMessage_In_Grid,1,rsv.GetItemStr("leave_fact_time").Mid(11,2)+"点"+rsv.GetItemStr("leave_fact_time").Mid(14,2)+"分,"+rsv.GetItemStr("leave_train_name")+"要牌,进"+dlg.m_sRail+"道");
to_enter_rail=dlg.m_sRail;
AddLog(lcjfAfxData.m_CurrentShift.strDate+lcjfAfxData.m_CurrentShift.strName,rsv.GetItemStr("leave_fact_time").Mid(11,2)+"点"+rsv.GetItemStr("leave_fact_time").Mid(14,2)+"分",dlg.m_sTrain+"要牌进"+dlg.m_sRail+"道");
}
else
{
rsv.MoveNext();
continue;
}
}
nMessage_In_Grid+=1;
rsv.MoveNext();
}
CStationMapView *p_map_view= (CStationMapView*)_GET_CLASS(RUNTIME_CLASS(CStationMapView));
if(p_map_view)
p_map_view->Invalidate();
SetFont(nMessage_In_Grid,2+theApp.Num_Zyd);
Invalidate();
strSQL="delete from lcxx";
_IF_DB_ERROR_EXIT(lcjfAfxData.m_adoDBConn.OpenAdoRsValues(strSQL,&rsv));
m_nRead=0;另外我想问一下如何在工具栏上面写一些汉字啊?
而且记录条也才10条左右,处理完后就删除
SetTimer(1,20000,NULL);
有什么解决办法啊??void CMainFrame::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
CInfoView *p_view= (CInfoView*)_GET_CLASS(RUNTIME_CLASS(CInfoView));
if(nIDEvent==1)
p_view->ReadDb();//扫描数据库
else if(nIDEvent==2)
p_view->ScanPorts();
CXTFrameWnd::OnTimer(nIDEvent);}
void readdb()
{
CAdoRsValues rsv;
CString strSQL;
CString zylx;
CString zydm;
int zylxdm;
if (m_nRead==0)
m_nRead=1;
else
return;
strSQL="select * from lcxx order by lsh";
_IF_DB_ERROR_EXIT(lcjfAfxData.m_adoDBConn.OpenAdoRsValues(strSQL,&rsv));
int i=1;
CString to_enter_rail;
while(!rsv.IsEndOfFile())
{
CAdoRsValues rsv1;
CString strSQL1;
CString zydm;
CString xh;
CString Rail;
xh.Format("%d",nMessage_In_Grid);
//上行要牌
if(!rsv.GetItemStr("leave_fact_time").IsEmpty()&&(rsv.GetItemStr("node_name")==theApp.UpwardYgz||rsv.GetItemStr("node_name")==theApp.UpwardYgz2)&&lcjfAfxData.GetTrainDirection(rsv.GetItemStr("leave_train_name")))
{
if(rsv.GetItemStr("leave_train_name").GetLength()>=5)
zylx="上行货车要牌";
else
zylx="上行客车要牌";
DlgTrainBlock dlg;
dlg.m_sTrain=rsv.GetItemStr("leave_train_name");
sndPlaySound(SOUND_NOTIFY,SND_ASYNC);
Sleep(1000);
sndPlaySound(SOUND_NOTIFY,SND_ASYNC);
Sleep(1000);
sndPlaySound(SOUND_NOTIFY,SND_ASYNC);
Sleep(1000);
if(dlg.DoModal()==IDOK)
{
Rail=dlg.m_sRail;
m_pGridCtrl->SetItemText(nMessage_In_Grid,0,xh);
m_pGridCtrl->SetItemText(nMessage_In_Grid,1,rsv.GetItemStr("leave_fact_time").Mid(11,2)+"点"+rsv.GetItemStr("leave_fact_time").Mid(14,2)+"分,"+rsv.GetItemStr("leave_train_name")+"要牌,进"+dlg.m_sRail+"道");
to_enter_rail=dlg.m_sRail;
AddLog(lcjfAfxData.m_CurrentShift.strDate+lcjfAfxData.m_CurrentShift.strName,rsv.GetItemStr("leave_fact_time").Mid(11,2)+"点"+rsv.GetItemStr("leave_fact_time").Mid(14,2)+"分",dlg.m_sTrain+"要牌进"+dlg.m_sRail+"道");
}
else
{
rsv.MoveNext();
continue;
}
}
nMessage_In_Grid+=1;
rsv.MoveNext();
}
CStationMapView *p_map_view= (CStationMapView*)_GET_CLASS(RUNTIME_CLASS(CStationMapView));
if(p_map_view)
p_map_view->Invalidate();
SetFont(nMessage_In_Grid,2+theApp.Num_Zyd);
Invalidate();
strSQL="delete from lcxx";
_IF_DB_ERROR_EXIT(lcjfAfxData.m_adoDBConn.OpenAdoRsValues(strSQL,&rsv));
m_nRead=0;另外我想问一下如何在工具栏上面写一些汉字啊?
想在工具栏上面写一些汉字,最好直接改用DialogBar.