怎样在VC列表框中更新输出结果
用m_result.UpdateData(FALSE); m_result.UpdateWindow();怎么不能,到底用什么?代码如下:
void CC3Dlg::OnDisplay()
{
// TODO: Add your control notification handler code here
//do{MessageBox("不在服务范围内,请重新输入!");
UpdateData(FALSE);
UpdateWindow();//这句不能少,否则不会立即生效
//}while(!check1(m_begin));
int v1=check2(m_begin);
//CString str2;
//GetDlgItemText(m_end,m_end);
//do{MessageBox("不在服务范围内,请重新输入!");
UpdateData(FALSE);
UpdateWindow();
//}while(!check1(m_end));
int v2=check2(m_end);
this->m_result.ResetContent();
//cin>>select;
switch(m_nkind)
{
case 0:{
//cout<<"test city xiabiao:"<<v1<<endl;
//得出begin end在g[]中的下标
//cout<<"test city xiabiao:"<<v2<<endl;
if(v2>=v1)
{int count=v2-v1+1;
//cout<<"the return value:"<<GetWeight(v1, v1+2, select)<<endl;
double *dist=new double[count];
int *path=new int[count];
pshortpath(v1,v2,m_nkind,dist,path);
this->m_result.AddString("两城市的最短行程距离为:");
this->m_result.SetCurSel(0);
this->m_result.AddString((CString)dist[count-1]);
this->m_result.SetCurSel(0);
this->m_result.AddString("千米");
this->m_result.AddString("两城市的最短行程路线为:");
CString temp;
CString Rcity[MaxV];
int t=v2;int v=0;
for(int k=0;k<count;k++)
{ if(t==v1)break;
else {
temp=GetValue(path[t]);
Rcity[v]=temp;
v++;
t=check2(temp);
}
}
//cout<<begin<<":";
int c=v-1;
for(int k1=0;k1<=c;k1++)
{ this->m_result.AddString(Rcity[v-1]);
v--;
}
m_result.AddString(m_end);
m_result.UpdateData(FALSE);
m_result.UpdateWindow();
/*
while(v0<count)
{
for(int v=count-1;v>=0;v--)
if((path[v]!=-1)&&(GetValue(path[v])==temp))//通过每次搜索出当前节点的下一结点
{
cout<<Rcity<<":";
Rcity=GetValue(v+v1);//逐个变化的应该可以实现,事实上是下标差作怪?
}
v0++;//count必需写在括号外,才能使循环结束
}
cout<<Rcity<<"."<<endl<<endl;//将最末的输出ok?
*/
}
else{
int count=v1-v2+1;
double *dist=new double[count];
int *path=new int[count];
pshortpath1(v1,v2,m_nkind,dist,path);
m_result.AddString("两城市的最短行程距离为:");
m_result.AddString((CString)dist[count-1]);
m_result.AddString("千米");
m_result.AddString("两城市的最短行程路线为:");
CString temp;
CString Rcity[MaxV];
int t=v2;int v=0;
for(int k=0;k<count;k++)
{ if(t==v1)break;
else {
temp=GetValue(path[t]);
Rcity[v]=temp;
v++;
t=check2(temp);
}
}
int c=v-1;
for(int k1=0;k1<=c;k1++)
{ m_result.AddString(Rcity[v-1]);
v--;
}
m_result.AddString(m_end);
}
}
break;