我把一系列名字换行保存在一个文本文件中,单行保存一个名字
VC读取该文本,将每一行的字符保存在字符数组中
并输出显示在列表控件的单列里
数组数量为10851该主要用处为一单机游戏外挂,读取游戏内存,按照内存定义的值找寻名称,并显示在列表空间中我试了两种列表控件SortListCtrl,还有一种,都是可排序的
发现一读取游戏内存,超过一定行数,如200行以上,就会出错一直未能发现原因,请教

解决方案 »

  1.   

    CListCtrl没有行数限制,即使行数很大(几万行以上),也只是界面刷新、绘图慢,不会出错。应该是你保存字符串的代码出错了
      

  2.   

    byte wp2data[2600][25];
    void CWP2PlusPlugDlg::On_readgame() 
    {
     CStdioFile Hrndat( _T( "Hrname.dat" ), CFile::modeRead );
     CStringArray hn;
     CString str = _T( "" );
     while ( Hrndat.ReadString( str ) )
     {
      hn.Add( str );
     }
          
     CString sh2,sh3,sh4,sh5,sh6,sh7,sh8,sh9,sh10,sh11,sh12,sh13,sh14,sh15;
    HWND gameh=::FindWindow(NULL,gameCaption);
    DWORD processid;
    ::GetWindowThreadProcessId(gameh,&processid);
    HANDLE processH=::OpenProcess(PROCESS_ALL_ACCESS,false,processid);
        DWORD byread;
    LPCVOID pbase=(LPCVOID)0x02E00000;
    LPVOID  nbuffer=(LPVOID)&wp2data;
    ::ReadProcessMemory(processH,pbase,nbuffer,2600*25,&byread);
    for(int k=0;k<50;k++){
            unsigned short int h1 = *(unsigned short int*)(&wp2data[k][0]);
    unsigned short int h2 = *(unsigned short int*)(&wp2data[k][2]);
    unsigned char h3 = *(unsigned char*)(&wp2data[k][5]);
    unsigned char h4 = *(unsigned char*)(&wp2data[k][6]);
    unsigned char h5 = *(unsigned char*)(&wp2data[k][7]);
    unsigned char h6 = *(unsigned char*)(&wp2data[k][9]);
    unsigned char h7 = *(unsigned char*)(&wp2data[k][12]);
    unsigned char h8 = *(unsigned char*)(&wp2data[k][13]);
    unsigned char h9 = *(unsigned char*)(&wp2data[k][14]);
    unsigned char h10 = *(unsigned char*)(&wp2data[k][15]);
    unsigned char h11 = *(unsigned char*)(&wp2data[k][16]);
    unsigned char h12 = *(unsigned char*)(&wp2data[k][17]);
    unsigned char h13 = *(unsigned char*)(&wp2data[k][18]);
    unsigned char h14 = *(unsigned char*)(&wp2data[k][19]);
    unsigned char h15 = *(unsigned char*)(&wp2data[k][21]);
    str=hn.GetAt(h1)+hn.GetAt(h2);
    sh2.Format(_T("%s"),str); 
    sh3.Format(_T("%d"),h3);
    sh4.Format(_T("%d"),h4);
    sh5.Format(_T("%d"),h5);
    sh6.Format(_T("%d"),h6);
    sh7.Format(_T("%d"),h7);
    sh8.Format(_T("%d"),h8);
    sh9.Format(_T("%d"),h9);
    sh10.Format(_T("%d"),h10);
    sh11.Format(_T("%d"),h11);
    sh12.Format(_T("%d"),h12);
    sh13.Format(_T("%d"),h13);
    sh14.Format(_T("%d"),h14);
    sh15.Format(_T("%d"),h15);

    m_ctlList.AddItem( _T(sh2), _T(sh3), _T(sh4), _T(sh5), _T(sh6), _T(sh7), _T(sh8), _T(sh9), _T(sh10), _T(sh11), _T(sh12), _T(sh13), _T(sh14), _T(sh15) );
    }
      

  3.   

    我印象中好像是要采用虚拟列表框的方法才能显示超过200条的记录。
    具体的说就是向列表框中添加记录不在用InsertItem之类的参数,而是列表框根据当前可见的列表项的行号,发送一个消息通知程序当前要显示第几行第几列,你在消息处理函数中得根据行号和列号填入相应字符就可以了。
    具体这个消息号的定义已经不记得了,我再帮你查查。你也可以在这网站搜搜。
      

  4.   

    出错应该不是listctrl的事情。跟踪下在哪一行出错的。
      

  5.   

    ON_NOTIFY(LVN_GETDISPINFO,IDC_LIST,&CXXXDlg::OnGetDispInfo)
    void CXXXDlg::OnGetDispInfo()
    {
      .....  LV_ITEM* pItem= &(pDispInfo)->item;  if(case) //case:是前三行
      {
      //插入你想要插入的数据
      }
      else
      {
      //你默认的代码
      }
    }
      

  6.   

    这个例子比较详细
    http://www.codeguru.com/cpp/controls/listview/advanced/article.php/c4151
      

  7.   

    谢谢 laomig ,但是是否有人可以帮我看下,我上面那些代码语句是否存在错误呢?