void CMyInfo2Dlg::OnButtonAppend()
{
// TODO: Add your control notification handler code here
CString strOne = _T("Left is what you can make it, so try to make it beautiful!");
CString strTwo = _T("Things can only get better!");
static int times = 0;
CString strMsg = _T("");
// Initialize character format structure
CHARFORMAT cf;
m_reditInfo.GetSelectionCharFormat(cf);
static int iHeight = 200;
cf.cbSize = sizeof(CHARFORMAT);
cf.dwMask |= CFM_BOLD;
cf.dwEffects |= CFE_BOLD;//设置粗体,取消用cf.dwEffects&=~CFE_BOLD;
cf.dwEffects &= ~CFE_AUTOCOLOR;
cf.dwMask |= CFM_COLOR;
cf.crTextColor = RGB(255, 0, 0);
cf.dwMask|= CFM_SIZE;
cf.yHeight = iHeight;//设置高度
cf.dwMask |= CFM_FACE;
_tcscpy(cf.szFaceName ,_T("微软雅黑"));//设置字体
for (int i = 0; i < 1000; i++)
{
if (times++ % 2 == 0)
{
strMsg = strOne;
}
else
{
strMsg = strTwo;
}
int pos = m_reditInfo.GetWindowTextLength();
m_reditInfo.SetSel(pos, -1);
// Set the character format
m_reditInfo.SetSelectionCharFormat(cf);
//strMsg = CString::Format("%5d ", i) + strMsg + _T("\r\n");
CString strIndex;
strIndex.Format(_T("%5d: "), i);
strMsg = strIndex + strMsg + _T("\r\n");
m_reditInfo.ReplaceSel(strMsg);
m_reditInfo.PostMessage(WM_VSCROLL, SB_BOTTOM, 0); // 滚动条滚动到最下方
Sleep(200);
UpdateData(FALSE);
}
}
http://www.cnblogs.com/qq78292959/archive/2011/08/30/2160056.html
https://msdn.microsoft.com/en-us/library/windows/desktop/aa816369(v=vs.85).aspx