Handling scrollbars in VC ++ 6.0 and MFC

Hai in vC ++ 6.0 MFC, I have connected the serial port when reading and displaying data (I want to display date and time) in the edit field (IDC_EDIT1),

My problem is that I was using a vertical scrollbar in the edit window. Whenever I show new data, the vertical scroll bar moves up; it should go down (scroll down),

Written code:

CString temp;
    static CString dat;
    static CString tim;

    if (dat != m_date || tim != m_time)
    {
        temp = "\r\n-------------------------------------------------------------------------------------------------\r\n\r\n";
        temp = temp + "Date: ";
        temp = temp + m_date;
        temp = temp + "\t\t\t";
        temp = temp + "Time: ";
        temp = temp + m_time;
        temp = temp + "\r\n-------------------------------------------------------------------------------------------------";
    }

    dat = m_date;
    tim = m_time;

    temp = temp + "\r\n\r\n";
    temp = temp + m_sensorname +"\t\t";
    temp = temp + m_value + "\t\t";
    temp = temp + m_units;

    if (m_datalog_id ==0x01)
        m_pdialog->m_editlog1= m_pdialog->m_editlog1 + temp;
    else if(m_datalog_id==0x02)
        m_pdialog->m_editlog2 = m_pdialog->m_editlog2 + temp;
    else
        return;

    m_pdialog->UpdateData(false);

      

0


source to share


1 answer


After you write the text in the edit control, call IDC_EDIT1.ScrollToCaret()

. This will scroll it down to where the newline is.



+3


source







All Articles