我想在线城中实现listbox滚动显示信息。

解决方案 »

  1.   

    ::SendMessage(hWndListBox, LB_SETSEL, (WPARAM)nItem, (LPARAM)FALSE);
      

  2.   

    刚才写错了,是发送LB_SETCARETINDEX的消息
      

  3.   

    能写具体点吗?比如:
    CString c="123";
       AfxBeginThread(display,p);UINT CAccessDlg::display(void *p)
    {
       ::SendMessage(hWndListBox, c, (WPARAM)nItem, (LPARAM)FALSE);
    }
    ??
      

  4.   

    DWORD WINAPI CAccessDlg::display(LPVOID pParam)
    {
    HWND hWndListBox = (HWND)pParam;
    int nItem = ::SendMessage(hWndListBox, LB_ADDSTRING, 0, (LPARAM)(LPCTSTR)"123");
    ::SendMessage(hWndListBox, LB_SETCARETINDEX, (WPARAM)nItem, (LPARAM)FALSE);
    return 0;
    }AfxBeginThread(display, GetDlgItem(IDC_LISTBOX1)->GetSafeHwnd());
      

  5.   

    error C2665: 'AfxBeginThread' : none of the 2 overloads can convert parameter 1 from type 'unsigned long (void *)'
    Error executing cl.exe.
      

  6.   

    UINT CAccessDlg::display(LPVOID pParam);
      

  7.   

    调试过程中
    UINT CExcelAccessDlg::display(LPVOID pParam)
    {
    HWND hWndListBox = (HWND)pParam;
    int nItem = ::SendMessage(hWndListBox, LB_ADDSTRING, 0, (LPARAM)(LPCTSTR)glostring);---到这跳出了????为什么??
    ::SendMessage(hWndListBox, LB_SETCARETINDEX, (WPARAM)nItem, (LPARAM)FALSE);
    return 0;
    }
      

  8.   

    在我的程序里没有问题啊,贴出你的display全部代码
      

  9.   

    AfxBeginThread(display, GetDlgItem(IDC_LISTACCESS)->GetSafeHwnd());
    CString glostring="1234";
    UINT CExcelAccessDlg::display(LPVOID pParam)
    {
    HWND hWndListBox = (HWND)pParam;
    int nItem = ::SendMessage(hWndListBox, LB_ADDSTRING, 0, (LPARAM)(LPCTSTR)glostring);
    ::SendMessage(hWndListBox, LB_SETCARETINDEX, (WPARAM)nItem, (LPARAM)FALSE);
    return 0;
    }
      

  10.   

    这段代码可以正常运行,IDC_LISTACCESS是一个LISTBOX还是LISTCTRL?
      

  11.   

    我找到问题了
    void CTestDlg::OnOK() 
    {
    for(;;)
    {     AfxBeginThread(display, GetDlgItem(IDC_LIST1)->GetSafeHwnd());
     int t=1;
    }
    }UINT CTestDlg::display(LPVOID pParam)
    {HWND hWndListBox = (HWND)pParam;
    int nItem = ::SendMessage(hWndListBox, LB_ADDSTRING, 0, (LPARAM)(LPCTSTR)glostring);--这样调用就会到此处不往下执行。
    ::SendMessage(hWndListBox, LB_SETCARETINDEX, (WPARAM)nItem, (LPARAM)FALSE);
    return 0;
    }
    但我想让它能循环执行,怎么办呢