将文本附加到 CEdit 控件后出现奇怪的字体效果

Strange font effect after when appending text to CEdit control

注意到界面更新缓慢后,我按照 CEdit SetWindowText rediculously slow 上的建议将文本附加到 CEdit 控件。

那我换了

void CMyPropertyPage::Log(const CString& sLog)
{
    CString str;
    m_cLogEdit.GetWindowText(str);

    if (!str.IsEmpty())
        str += _T("\r\n");

    str += sLog;

    m_cLogEdit.SetWindowText(str);
    m_cLogEdit.LineScroll(m_cLogEdit.GetLineCount());
}

来自

void CMyPropertyPage::Log(const CString& sLog)
{
    m_cLogEdit.SetSel(-1,-1);
    m_cLogEdit.ReplaceSel(sLog + L"\r\n");

    //m_cLogEdit.LineScroll(m_cLogEdit.GetLineCount());

    UpdateData(FALSE);
    UpdateWindow();
}

现在,当我 运行 它时,我注意到奇怪的字体模糊,因为它在图像中日志文本框的前两行中可见。

这是什么原因,我该如何解决?

我解决了:)

void CMyPropertyPage::Log(const CString& sLog)
{
    m_cLogEdit.SetRedraw(FALSE);

    m_cLogEdit.SetSel(-1,-1);
    m_cLogEdit.ReplaceSel(sLog + L"\r\n");

    m_cLogEdit.SetRedraw(TRUE);

    m_cLogEdit.LineScroll(m_cLogEdit.GetLineCount());

    UpdateData(FALSE);
    m_cLogEdit.UpdateWindow();
}

看来如果我暂时禁用重绘问题就解决了!