我创建的listbox是用来提示信息的,所以当信息量多于listbox高度时会出现vscroll,可是提示信息没有显示出来,得手工拉动vscroll才可以看到,如果想让vscroll一直处于最下端应该怎么做?

解决方案 »

  1.   

    LB_SETCURSEL
    An application sends an LB_SETCURSEL message to select a string and scroll it into view, if necessary. When the new string is selected, the list box removes the highlight from the previously selected string. To send this message, call the SendMessage function with the following parameters. SendMessage( 
      (HWND) hWnd,        // handle to destination window 
      LB_SETCURSEL,       // message to send
      (WPARAM) wParam,    // item index
      (LPARAM) lParam     // not used; must be zero
    );
    计算当前的行数,然后wParam传count-1
      

  2.   

    CListBox   m_list;
                      static   int   a=1;
    CString   str;int   b=0;
    str.Format( "第%d条 ",a++);
    m_list.InsertString(m_list.GetCount(),str);
    b=m_list.GetCount();
    //m_list.SetFocus();
    m_list.SetCurSel(b-1);
    这样每次输入数据后,数据自动成为最后一条,而且选中的也是当前插入的这条