如何在CEDIT里逐行显示内容啊?

wddlqd 2006-01-25 10:23:00
就是我想以log文的显示输出在CEDIT控件里,一捕捉到信息,就输出到CEDIT内,但是又不把前面的内容覆盖?
...全文
204 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
jerry 2006-01-25
  • 打赏
  • 举报
回复
没有绑定:
CEdit* p = (CEdit*)GetDlgItem(IDC_EDIT);

如果是SDK(没有MFC)

用消息代替:

SetSel : EM_SETSEL
ReplaceSel : EM_REPLACESEL



SendDlgItemMessage(hDlg, IDC_EDIT, EM_SETSEL, (WPARAM)-1, (LPARAM)-1);
SendDlgItemMessage(hDlg, IDC_EDIT, EM_SETSEL, (WPARAM)0, (LPARAM)TEXT("abcdefg"));
jerry 2006-01-25
  • 打赏
  • 举报
回复
插入最后:(CEdit)

SetSel(-1,-1);
ReplaceSel("aaaa");
wddlqd 2006-01-25
  • 打赏
  • 举报
回复
谢谢
striking 2006-01-25
  • 打赏
  • 举报
回复
重载CEdit 例如 CHistoryEdit , 增加下面的函数
void CHistoryEdit::AppendString
(CString str)
{
CString strBuffer; // current contents of edit control

// Append string
GetWindowText (strBuffer);
if (!strBuffer.IsEmpty())
strBuffer += "\r\n";
strBuffer += str;
SetWindowText (strBuffer);

// Scroll the edit control
LineScroll (GetLineCount(), 0);
}

15,978

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧