循环测试和list control显示问题
大家好,我想做个自动测试系统,点击开始按键,进行每组数组比较,如果"PASS”"继续测试,每行背景为绿色,如果"FAIL"则退出测试,背景颜色为红色。我想一行一行比较完输入,问题现在是数据一起插入到list control控件,颜色也不对,烦请大家指导下,谢谢。。
List control.rar
(3.45 MB)
void CListcontroldexamDlg::OnButton5()
{
// TODO: Add your control notification handler code here
i++;
TestResult(i);
TestSequence(i);
}
void CListcontroldexamDlg::InitalTestItems()
{
value[0]=5.0;
value[1]=4.5;
value[2]=4.0;
value[3]=5.0;
value[4]=4.7;
value[5]=4.33;
value[6]=2.5;
value[7]=5.0;
value[8]=3.5;
value[9]=9.0;
high[0]=5.0;
high[1]=4.5;
high[2]=4.0;
high[3]=5.0;
high[4]=4.7;
high[5]=4.33;
high[6]=2.5;
high[7]=5.0;
high[8]=3.5;
high[9]=5.0;
low[0]=2.5;
low[1]=2.5;
low[2]=2.5;
low[3]=2.0;
low[4]=2.5;
low[5]=2.5;
low[6]=0.5;
low[7]=2.5;
low[8]=1.5;
low[9]=2.0;
testitem[0]="Rise Time1(Low)";
testitem[1]="Fall Time1(Low)";
testitem[2]="VTop1(Low)";
testitem[3]="VBase1(Low)";
testitem[4]="Rise Time2(Low)";
testitem[5]="Fall Time2(Low)";
testitem[6]="VTop2(Low)";
testitem[7]="VBase2(Low)";
testitem[8]="Rise Time11(High)";
testitem[9]="Fall Time11(High)";
}
BOOL CListcontroldexamDlg::TestResult(int TestNum)
{
if ((value[TestNum]<=high[TestNum])&&(value[TestNum]>=low[TestNum])) {
result[TestNum] = "PASS";
Final=1;
}
else {
result[TestNum] = "FAIL";
Final=0;
}
return Final;
}
void CListcontroldexamDlg::TestSequence(int TestNum)
{
int nIndex1=m_listCtrl.GetItemCount();//默认插入到最后
CString TestSequence=testitem[TestNum];
int Nrow=m_listCtrl.InsertItem(nIndex1,TestSequence);
CString Up,Down,Val,Status;
Up.Format(_T("%0.2f"),high[TestNum]);
Down.Format(_T("%0.2f"),low[TestNum]);
Val.Format(_T("%0.2f"),value[TestNum]);
Status.Format(_T("%s"),result[TestNum]);
m_listCtrl.SetItemText(Nrow,1,Up);
m_listCtrl.SetItemText(Nrow,2,Down);
m_listCtrl.SetItemText(Nrow,3,Val);
m_listCtrl.SetItemText(Nrow,4,Status);
if(Final==1)
{
m_listCtrl.SetTextBkColor(RGB(0,255,0));
}
else{
m_listCtrl.SetTextBkColor(RGB(255,0,0));
}
}