我想通过单击按钮——>打开文件对话框,当选择了要打开的文本文件后,除了把文件的完整路径和名字显示在edit中外,还想把文件的内容显示出来,我在这里选择使用listctrl控件,由于初次使用,不熟悉,系统编译时报错:error C2228: left of '.SetItemText' must have class/struct/union type,我想了好久,在网上也没找到答案,所以只有求助了。另外,还有一个问题:listctrl和listbox标志性区别是什么,像我这种情况,用哪一个更好些?代码如下:
CString FileName;
  CFileDialog browse(TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, NULL, NULL );
  if (browse.DoModal()==IDOK)
  {
    FileName=browse.GetPathName();
  }
  GetDlgItem(IDC_EDIT1)->SetWindowText(FileName);  //读取文件内容
  int N;
  sample* dot;
  ifstream fin;
  CListCtrl m_list; 
  fin.open(FileName, ios::in);
  if(fin == NULL)
    exit(0);
  fin >> N;
  dot=new sample[N+1];
  for(int i=1; i<=N; i++)
  {
  fin>>dot[i].number>>dot[i].pt.x>>dot[i].pt.y>>dot[i].pt.z;
  m_list.InsertItem(m_list.GetItemCount(),   " ");
  m_list.SetItemText(i, 1, dot[i].number);
  m_list.SetItemText(i, 2, dot[i].pt.x);
  m_list.SetItemText(i, 3, dot[i].pt.y);
  m_list.SetItemText(i, 4, dot[i].pt.z);
  }
  fin.close();