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
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
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);
这样每次输入数据后,数据自动成为最后一条,而且选中的也是当前插入的这条