1.添加Edit控件,设置其属性
2.Button "Result" 的消息函数如下
int CTestMFC2Dlg::m_Count = 0;
void CTestMFC2Dlg::OnBnClickedButtonResult()
{
// TODO: 在此添加控件通知处理程序代码
LOGFONT lf;
// clear out structure.
memset(&lf, 0, sizeof(LOGFONT));
// request a 12-pixel-height font
lf.lfHeight = 90;
// request a face name "Arial".
_tcsncpy_s(lf.lfFaceName, LF_FACESIZE, _T("Arial"), 7);
CClientDC dc(this);
CFont outputFont;
VERIFY(outputFont.CreatePointFontIndirect(&lf, &dc));
richeditResult.SetModify(FALSE);
richeditResult.SetFont(&outputFont,TRUE);
richeditResult.SetWindowTextW(_T(""));
richeditResult.SetSel(1, -1);
CString m_strResult;
for(int i = m_Count; i<m_Count + 5 ; i++)
{
CString strNum = _T("");
strNum.Format(_T("%d:"), i);
m_strResult += strNum;
m_strResult += _T("将剪贴板中的数据插入到当前光标位置的编辑控件中。");
m_strResult += _T("\r\n\r\n");
}
richeditResult.ReplaceSel(m_strResult);
m_Count+=5;
outputFont.DeleteObject();
}
3.效果
4.完整的项目代码
链接:https://pan.baidu.com/s/1otwsRJ8bfn9BqzG0UEZPfw
提取码:efnh
文章转自:http://liyanliang.net/cricheditctrl%e6%9b%b4%e6%94%b9%e4%b8%babcgcontrolbar%e7%9a%84cbcgpedit/