VS_MFC: The edit box wraps automatically, and the vertical scroll bar moves down automatically

1. Create a new edit box control (Edit Control), tick the Multiline in front of it (set the property to True), and remove the tick in front of Auto HScroll (set the property to False), so that each line can be filled. Wrapped automatically.

2. Tick the vertical scroll bar (the property is set to True), and the vertical scroll bar will appear when the input or display exceeds the size of the edit box.

3. If it is input, the scroll bar will automatically move to follow the current input line, but if it is set to display a lot of content at one time in the edit box, the scroll bar will always be at the top, and you need to manually pull it to the bottom to see the last line. The content, in many cases, we do not need, but want the scroll bar to be at the bottom, the following code will achieve this function:

this->SetDlgItemText(IDC_EDIT_RECV,str);//Display the content of the string str to the edit box whose ID is IDC_EDIT_RECV
m_recvshw.LineScroll(m_recvshw.GetLineCount());//m_recvshw is a member variable of the edit box (that is, control type variable)
//Use some member functions of the control variable to set the position of the scroll bar

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325999313&siteId=291194637